当前位置:网站首页>功能: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
边栏推荐
- 使用 Abp.Zero 搭建第三方登录模块(一):原理篇
- Pytorch深度学习代码技巧
- 房东拿租金去还房贷是天经地义的嘛
- Go变量的声明与赋值
- Principle of TCP reset attack
- RestCloud ETL抽取动态库表数据实践
- RestCloud ETL抽取動態庫錶數據實踐
- Bank of Beijing x Huawei: network intelligent operation and maintenance tamps the base of digital transformation service
- R语言使用epiDisplay包的aggregate函数将数值变量基于因子变量拆分为不同的子集,计算每个子集的汇总统计信息、使用aggregate.data.frame函数计算分组汇总统计信息
- 使用RestCloud ETL Shell组件实现定时调度DataX离线任务
猜你喜欢

Authoritative announcement on the recruitment of teachers in Yan'an University in 2022

15 bs对象.节点名称.节点名称.string 获取嵌套节点内容

关于 selenium.common.exceptions.WebDriverException: Message: An unknown server-side error 解决方案(已解决)
杜老师说网站更新图解

Notes on writing questions in C language -- table tennis competition

获取两个dataframe的交并差集

Document 1

Deploy the flask environment using the pagoda panel

Common operation and Principle Exploration of stream

详解C语言编程题:任意三条边能否构成三角形,输出该三角形面积并判断其类型
随机推荐
Get the intersection union difference set of two dataframes
The tablestack function of the epidisplay package of R language makes a statistical summary table (descriptive statistics of groups, hypothesis test, etc.), does not set the by parameter to calculate
Mark一下 Unity3d在Inspector中选中不了资源即Project锁定问题
子查询的使用
Excel-VBA 快速上手(二、条件判断和循环)
The intersect function in the dplyr package of R language obtains the data lines that exist in both dataframes and the data lines that cross the two dataframes
cluster addslots建立集群
Kubernetes的pod调度
clustermeet
Naacl2022: (code practice) good visual guidance promotes better feature extraction, multimodal named entity recognition (with source code download)
券商经理给的开户二维码安全吗?找谁可以开户啊?
IP certificate application process of sectigo
TCP拥塞控制详解 | 1. 概述
Unity 利用Skybox Panoramic着色器制作全景图预览有条缝隙问题解决办法
redis集群的重新分片与ASK命令
Redis-集群
Authoritative announcement on the recruitment of teachers in Yan'an University in 2022
印尼投资部长:鸿海考虑在其新首都建立电动公交系统、城市物联网
Talk about the RPA direction planning: stick to simple and valuable things for a long time
获取两个dataframe的交并差集