Skip to content

Instantly share code, notes, and snippets.

@legend80s
legend80s / Crypto.js
Last active April 8, 2022 07:28
AES/ECB/PKCS5Padding Cipher and Decipher of Node.js and can communicate with other languages
// modified based on [node.js AES/ECB/PKCS5Padding 与其他语言的加密解密通用](http://yijiebuyi.com/blog/13e2ae33082ac12ba4946b033be04bb5.html)
const crypto = require('crypto');
module.exports = class Crypto {
/**
* 加解密必须使用同一套 key 和 iv
* @param {String} algorithm 算法名称,比如 `aes-128-ecb`
* @param {String} key 秘钥
* @param {String} iv initialization vector,默认空字符串
*/