UNPKG

netpower-ng

Version:

A common library that can be used for fe and be

27 lines 1.07 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var crypto = require("crypto"); var algorithm = 'aes-256-ctr'; var secretKey = 'vOVH6sdmpNWjRRIqCc7rdxs01lwHzfr3'; var iv = 'GbgYCZxhMssaqRBG'; var Cipher = /** @class */ (function () { function Cipher() { } Cipher.encrypt = function (text, secret) { var cipher = crypto.createCipheriv(algorithm, secret !== null && secret !== void 0 ? secret : secretKey, iv); var encrypted = Buffer.concat([cipher.update(text), cipher.final()]); return encrypted.toString('hex'); }; Cipher.decrypt = function (hash, secret) { var decipher = crypto.createDecipheriv(algorithm, secret !== null && secret !== void 0 ? secret : secretKey, iv); var decrpyted = Buffer.concat([ decipher.update(Buffer.from(hash, 'hex')), decipher.final() ]); var ret = decrpyted.toString(); return ret; }; return Cipher; }()); exports.default = Cipher; //# sourceMappingURL=cipher.js.map