UNPKG

qw-utils

Version:

qw Utils package

28 lines (27 loc) 951 B
"use strict"; var _interopRequireDefault = require("/Users/lxy/qw-utils/node_modules/@babel/runtime/helpers/interopRequireDefault.js").default; var _defineProperty2 = _interopRequireDefault(require("/Users/lxy/qw-utils/node_modules/@babel/runtime/helpers/esm/defineProperty.js")); var _cryptoJs = _interopRequireDefault(require("crypto-js")); const CFG_KEY = 'qw-utils'; class cryptoUtils { constructor() { /** * 加密 * @param message 待加密字符串 */ (0, _defineProperty2.default)(this, "encrypt", message => { return _cryptoJs.default.AES.encrypt(message, CFG_KEY).toString(); }); /** * 解密 * @param ciphertext 待解密字符串 */ (0, _defineProperty2.default)(this, "decrypt", ciphertext => { const bytes = _cryptoJs.default.AES.decrypt(ciphertext, CFG_KEY); return bytes.toString(_cryptoJs.default.enc.Utf8); }); } } module.exports = { cryptoUtils };