wx-ding-aes
Version:
Wechat open platform, Enterprise wechat and DingTalk AES decode library.
13 lines (12 loc) • 577 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const aes_1 = require("./aes");
const utils_1 = require("./utils");
const defaultRandomStringLength = 4;
exports.encode = (text, encodingAESKey, randomLength) => aes_1.encrypt(Buffer.from(`${utils_1.randomStr(randomLength === undefined ?
defaultRandomStringLength :
randomLength)}${text}`), encodingAESKey);
exports.decode = (text, encodingAESKey, randomLength) => aes_1.decrypt(text, encodingAESKey)
.slice(randomLength === undefined ?
defaultRandomStringLength :
randomLength);