zoukankan      html  css  js  c++  java
  • 前端Crypto.JS加密解密

    先下载CryptoJS并引入
    1、Hex格式:
    const key = CryptoJS.enc.Utf8.parse("cmp_security_key");
        const options = {
          mode: CryptoJS.mode.ECB,
          padding: CryptoJS.pad.Pkcs7
       }
    加密
     const encryptedStr = CryptoJS.AES.encrypt("222", key, options).ciphertext.toString();
    console.log(encryptedStr);
    解密
     const testdec = CryptoJS.AES.decrypt(CryptoJS.enc.Base64.stringify(CryptoJS.enc.Hex.parse(encryptedStr)), key, options).toString(CryptoJS.enc.Utf8);
     console.log(testdec);

    2、Base64

    加密

        const encryptedStr1 = CryptoJS.AES.encrypt("222", key, options).toString();

       console.log(encryptedStr1);

    解密

        const testdec1 = CryptoJS.AES.decrypt(encryptedStr1, key, options).toString(CryptoJS.enc.Utf8);
        console.log(testdec1);
  • 相关阅读:
    uwsgi+nginx+django
    uwsgi怎么启动停止
    centos7 命令
    django 配置静态文件
    centos7 安装node
    python 字符串拼接
    Python 编码
    python 文件夹递归
    ArcGIS二次开发的几种方式
    集合的操作
  • 原文地址:https://www.cnblogs.com/lzfj/p/13691789.html
Copyright © 2011-2022 走看看