encrypt.js
const c = require("crypto-js");
var x = {};
x.encrypt = function(key, iv, data)
{
key = c.enc.Utf8.parse(key);
iv = c.enc.Utf8.parse(iv);
data = c.enc.Utf8.parse(data);
var option = {
iv: iv,
mode: c.mode.CBC,
padding: c.pad.Pkcs7
};
return c.AES.encrypt(data, key, option).toString();
};
x.decrypt = function(key, iv, data)
{
key = c.enc.Utf8.parse(key);
iv = c.enc.Utf8.parse(iv);
var option = {
iv: iv,
mode: c.mode.CBC,
padding: c.pad.Pkcs7
};
var decrypt = c.AES.decrypt(data, key, option);
return c.enc.Utf8.stringify(decrypt).toString();
};
module.exports = x;
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。