/*
 * @Author: Gui
 * @Date: 2023-07-04 11:59:05
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2023-07-20 13:34:57
 * @Description: tel files
 * @filePath:
 */
import CryptoJS from "crypto-js";

const ShakeDownEncrypt = function (message) {
  const keyHex = CryptoJS.enc.Utf8.parse("telaidian123.com/Secret");
  const ivHex = CryptoJS.enc.Utf8.parse("ap.telaidian123.com");
  const srcs = CryptoJS.enc.Utf8.parse(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) {
  if (!message) {
    return message;
  }
  const keyHex = CryptoJS.enc.Utf8.parse("telaidian123.com/Secret");
  const ivHex = CryptoJS.enc.Utf8.parse("ap.telaidian123.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 decryptedStr.toString();
};
export { ShakeDownEncrypt, ShakeDownDecrypt };
