"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Des3Util = void 0;
const CryptoJS = require("crypto-js");
/**
 * 非标3DES加解密
 */
class Des3Util {
    /**
     * 加密
     */
    static encrypt(data, key, iv) {
        data = typeof data === "string" ? data : JSON.stringify(data, (k, v) => {
            return k === "imageInfo" ? undefined : v;
        });
        return CryptoJS.TripleDES.encrypt(data, CryptoJS.enc.Utf8.parse(key), {
            padding: CryptoJS.pad.Pkcs7,
            mode: CryptoJS.mode.CBC,
            iv: CryptoJS.enc.Utf8.parse(iv)
        }).toString();
    }
    /**
     * 解密
     */
    static decrypt(data, key, iv) {
        return CryptoJS.TripleDES.decrypt(data, CryptoJS.enc.Utf8.parse(key), {
            padding: CryptoJS.pad.Pkcs7,
            mode: CryptoJS.mode.CBC,
            iv: CryptoJS.enc.Utf8.parse(iv)
        }).toString(CryptoJS.enc.Utf8);
    }
}
exports.Des3Util = Des3Util;
