qw-utils
Version:
qw Utils package
32 lines (31 loc) • 953 B
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.cryptoUtils = void 0;
const crypto_js_1 = __importDefault(require("crypto-js"));
const CFG_KEY = 'qw-utils';
/**
* 加密解密工具类
*/
class cryptoUtils {
constructor() {
/**
* 加密
* @param message 待加密字符串
*/
this.encrypt = (message) => {
return crypto_js_1.default.AES.encrypt(message, CFG_KEY).toString();
};
/**
* 解密
* @param ciphertext 待解密字符串
*/
this.decrypt = (ciphertext) => {
const bytes = crypto_js_1.default.AES.decrypt(ciphertext, CFG_KEY);
return bytes.toString(crypto_js_1.default.enc.Utf8);
};
}
}
exports.cryptoUtils = cryptoUtils;