/*
 * @Author: Gui
 * @Date: 2023-07-04 11:59:05
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2023-07-04 12:01:32
 * @Description: kxs files
 * @filePath:
 */
import CryptoJS from "crypto-js";

// 调试加密：
const ShakeDownEncrypt = function (message) {
  const keyHex = CryptoJS.enc.Utf8.parse("kexiaoshuang.com/Secret");
  const ivHex = CryptoJS.enc.Utf8.parse("ap.kexiaoshuang.com");
  const srcs = CryptoJS.enc.Utf8.parse(JSON.stringify(message));
  const encrypted = CryptoJS.TripleDES.encrypt(srcs, keyHex, {
    iv: ivHex,
    mode: CryptoJS.mode.CBC,
    padding: CryptoJS.pad.Pkcs7
  });
  return encrypted.toString();
};
// 调试解密：
const ShakeDownDecrypt = function (message) {
  const keyHex = CryptoJS.enc.Utf8.parse("kexiaoshuang.com/Secret");
  const ivHex = CryptoJS.enc.Utf8.parse("ap.kexiaoshuang.com");
  const base64 = CryptoJS.enc.Base64.parse(message);
  const src = CryptoJS.enc.Base64.stringify(base64);
  const decrypt = CryptoJS.TripleDES.decrypt(src, keyHex, {
    iv: ivHex,
    mode: CryptoJS.mode.CBC,
    padding: CryptoJS.pad.Pkcs7
  });
  const decryptedStr = decrypt.toString(CryptoJS.enc.Utf8);
  return JSON.parse(decryptedStr.toString());
};
export { ShakeDownEncrypt, ShakeDownDecrypt };
