zoukankan      html  css  js  c++  java
  • crypto-js 3DES 加密解密

    // 3des解密
    export const decrypt = (params: any) => {
      const pubKey = localStorage.getItem('server_key');
      if (pubKey == null) {
        throw new Error('missing server pubKey');
      }
      const keyHex = CryptoJS.enc.Utf8.parse(HashHelper.Md5(pubKey));
      const decrypted = CryptoJS.TripleDES.decrypt(decodeURIComponent(params), keyHex, {
        mode: CryptoJS.mode.ECB,
        padding: CryptoJS.pad.Pkcs7
      });
      return decrypted.toString(CryptoJS.enc.Utf8);
    };
    // 3des加密
    export const encrypt = (params: any) => {
      const pubKey = localStorage.getItem('server_key');
      if (pubKey == null) {
        throw new Error('missing server pubKey');
      }
      const keyHex = CryptoJS.enc.Utf8.parse(pubKey);
      const encrypted = CryptoJS.TripleDES.encrypt(params, keyHex, {
        mode: CryptoJS.mode.ECB,
        padding: CryptoJS.pad.Pkcs7
      });
      return encrypted.toString();
    };
  • 相关阅读:

    类(重要的很)
    异常
    异常
    面向对象oop接口
    面向对象oop多态
    Day10_数组(下)
    Day09_数组(上)
    Day08_网络编程(上)
    Day07_java对象下
  • 原文地址:https://www.cnblogs.com/huangmin1992/p/15268524.html
Copyright © 2011-2022 走看看