"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Des3Util = void 0;
var crypto = require("crypto");
/**
 * 非标3DES加解密
 */
var Des3Util = /** @class */ (function () {
    function Des3Util() {
    }
    /**
     * 加密
     */
    Des3Util.encrypt = function (data, key, iv) {
        var cipher = crypto.createCipheriv("des-ede3-cbc", key, iv);
        var encrypted = null;
        if (typeof data === "string") {
            encrypted = cipher.update(data, "utf8", "base64");
        }
        else {
            var json = JSON.stringify(data, function (k, v) {
                return k === "imageInfo" ? undefined : v;
            });
            encrypted = cipher.update(json, "utf8", "base64");
        }
        encrypted += cipher.final("base64");
        return encrypted;
    };
    /**
     * 解密
     */
    Des3Util.decrypt = function (data, key, iv) {
        var decipher = crypto.createDecipheriv("des-ede3-cbc", key, iv);
        var decrypted = decipher.update(data, "base64", "utf8");
        decrypted += decipher.final("utf8");
        return decrypted;
    };
    return Des3Util;
}());
exports.Des3Util = Des3Util;
//# sourceMappingURL=Des3Util.js.map