当前位置:网站首页>功能:crypto-js加密解密
功能:crypto-js加密解密
2022-06-26 14:51:00 【[email protected]】
一、需求背景及crypto实现原理
待补充
二、安装使用
2.1、安装
yarn add crypto-js
2.2、在utils.js引入插件
const CryptoJS = require('crypto-js')
2.3、utils.js文件里 封装加密、解密方法
const key = CryptoJS.enc.Utf8.parse('xxxx_aes_v1_mweb')
// 解密方法
export function Decrypt(word) {
let decrypt = CryptoJS.AES.decrypt(word, key, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 })
let decryptedStr = decrypt.toString(CryptoJS.enc.Utf8)
return decryptedStr.toString()
}
// 加密方法
export function Encrypt(word) {
let srcs = CryptoJS.enc.Utf8.parse(word)
let encrypted = CryptoJS.AES.encrypt(srcs, key, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 })
return encrypted.toString()
}
2.4、页面使用
2.4.1、引入方法
import { Encrypt, Decrypt } from '@const/utils';
2.4.2、使用
let EData = Encrypt(111111)
console.log('151', EData)
console.log('151', Decrypt(EData))
2.4.3、效果
2.5、相关
很多情况说到加解密会想到MD5,MD5是一个散列算法,不能进行加解密。
三、欢迎交流指正,关注我,一起学习
四、参考链接:
crypto-js 加密、解密使用方法_deardanyang的博客-CSDN博客_crypto-js
版权声明
本文为[[email protected]]所创,转载请带上原文链接,感谢
https://blog.csdn.net/snowball_li/article/details/125423127
边栏推荐
- Redis-集群
- RestCloud ETL抽取动态库表数据实践
- Minister of investment of Indonesia: Hon Hai is considering establishing electric bus system and urban Internet of things in its new capital
- Datasets dataset class (2)
- [async/await] - the final solution of asynchronous programming
- NVIDIA SMI error
- Go变量的声明与赋值
- Unity UnityWebRequest 下载封装
- Redis cluster messages
- Transformers datacollatorwithpadding class
猜你喜欢
Stream常用操作以及原理探索
feil_uVission4左侧工目录消失
View触摸分析
15 BS object Node name Node name String get nested node content
Notes on writing questions in C language -- table tennis competition
Redis-集群
JVM 输出 GC 日志导致 JVM 卡住,我 TM 人傻了
Solution to the upper limit of TeamViewer display devices
One copy ten, CVPR oral was accused of plagiarizing a lot, and it was exposed on the last day of the conference!
Attention meets geometry: geometry guided spatiotemporal attention consistency self supervised monocular depth estimation
随机推荐
Mark一下 Unity3d在Inspector中选中不了资源即Project锁定问题
cluster addslots建立集群
Unity C# 网络学习(八)——WWW
编译配置in文件
Is it safe for flush to register and open an account? Is there any risk?
Notes on writing questions in C language -- table tennis competition
Go变量的声明与赋值
【soloπ】adb连接单个多个手机
Transformers datacollatorwithpadding class
Is the account opening link given by the broker manager safe? Who can I open an account with?
Deploy the flask environment using the pagoda panel
乐鑫 AWS IoT ExpressLink 模组达到通用可用性
One copy ten, CVPR oral was accused of plagiarizing a lot, and it was exposed on the last day of the conference!
重磅白皮书发布,华为持续引领未来智慧园区建设新模式
Redis集群消息
使用 Abp.Zero 搭建第三方登录模块(一):原理篇
Practical website recommendations worth collecting for College Students
印尼投资部长:鸿海考虑在其新首都建立电动公交系统、城市物联网
Optimizing for vectorization
R语言使用glm函数构建泊松对数线性回归模型处理三维列联表数据构建饱和模型、使用step函数基于AIC指标实现逐步回归筛选最佳模型、使用summary函数查看简单模型的汇总统计信息