// aes对称加密
const CryptoJS = require('crypto-js'); //引用AES源码js const key = CryptoJS.enc.Utf8.parse("1234123412ABCDEF"); //十六位十六进制数作为密钥
const iv = CryptoJS.enc.Utf8.parse('ABCDEF1234123412'); //十六位十六进制数作为密钥偏移量 //解密方法
function Decrypt(word) {
let encryptedHexStr = CryptoJS.enc.Hex.parse(word);
let srcs = CryptoJS.enc.Base64.stringify(encryptedHexStr);
let decrypt = CryptoJS.AES.decrypt(srcs, key, { iv: iv, mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.Pkcs7 });
let decryptedStr = decrypt.toString(CryptoJS.enc.Utf8);
return decryptedStr.toString();
} //加密方法
function Encrypt(word) {
let srcs = CryptoJS.enc.Utf8.parse(word);
let encrypted = CryptoJS.AES.encrypt(srcs, key, { iv: iv, mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.Pkcs7 });
return encrypted.ciphertext.toString().toUpperCase();
}

最新文章

  1. iMetro
  2. [Linux]cmd to use
  3. UDP模式聊天
  4. Windows Server 2008 R2 每隔一段时间自动关机解决办法
  5. 《深入理解bootstrap》读书笔记:第一章 入门准备
  6. erlang尾递归的概括
  7. MySQL数据库获取多个汉字拼音的首字母函数
  8. SCCM 2007 R2部署、操作详解系列之概念
  9. app视觉设计艺术(读书笔记)
  10. [cocoapods] 如何卸载工程里的cocoapods
  11. codeforces C. Restore Graph
  12. LeetCode——Rotate List
  13. (4)activiti之uel表达式
  14. Jmeter + Ant 测试环境搭建 及解决问题: the <jmeter> type doesn't support nested text data
  15. 深入理解Java虚拟机阅读心得(三)
  16. vimrc同步文档
  17. 2、jeecg 笔记之 t:dictSelect 或 t:dgCol 自定义字典
  18. C基础学习笔记
  19. Running kubernetes on windows
  20. 重写nyoj2——括号匹配

热门文章

  1. java 进阶P-2.3+P-2.4
  2. Android原生集成JPush SDK
  3. 【随笔记】全志平台 gpio-leds 驱动应用
  4. 用GC的策略,管理团队的技术债务
  5. 使用pycharm打开sqlite的问题
  6. 命令行部署KingbaseES流复制+切换测试
  7. C#中的Byte,String,Int,Hex之间的转换函数
  8. Zstack救急实战记录
  9. 合肥光源储存环束流三维参数测量系统相关PV
  10. STL中的智能指针(Smart Pointer)及其源码剖析: std::auto_ptr