UNPKG

@lark-project/cli

Version:

飞书项目插件开发工具

31 lines (30 loc) 1.09 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.decrypt = exports.encrypt = void 0; const crypto_1 = __importDefault(require("crypto")); const constants_1 = require("../config/constants"); /** 使用 aes256 算法进行加密 */ const encrypt = (text) => { if (!text) { return ''; } const cipher = crypto_1.default.createCipheriv('aes256', constants_1.PASSWORD, constants_1.IV); let encrypted = cipher.update(text, 'utf8', 'hex'); encrypted += cipher.final('hex'); return encrypted; }; exports.encrypt = encrypt; /** 使用 aes256 算法进行解密 */ const decrypt = (text) => { if (!text) { return ''; } const decipher = crypto_1.default.createDecipheriv('aes256', constants_1.PASSWORD, constants_1.IV); let decrypted = decipher.update(text, 'hex', 'utf8'); decrypted += decipher.final('utf8'); return decrypted; }; exports.decrypt = decrypt;