This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// modified based on [node.js AES/ECB/PKCS5Padding 与其他语言的加密解密通用](http://yijiebuyi.com/blog/13e2ae33082ac12ba4946b033be04bb5.html) | |
import crypto, { BinaryLike, Encoding } from 'crypto'; | |
import _ from 'lodash'; | |
export class CryptoUtil { | |
/** | |
* 加解密必须使用同一套 key 和 iv | |
* @param {String} algorithm 算法名称,比如 `aes-128-ecb` | |
* @param {String} key 秘钥 | |
* @param {String} iv initialization vector,默认空字符串 |