This commit is contained in:
xiaojunnuo
2025-01-15 01:26:23 +08:00
parent 14cdb54212
commit d6b3142a02
8 changed files with 77 additions and 148 deletions
@@ -2,8 +2,8 @@ import crypto from 'crypto';
export class Encryptor {
secretKey: Buffer;
constructor(encryptSecret: string) {
this.secretKey = Buffer.from(encryptSecret, 'base64');
constructor(encryptSecret: string, encoding: BufferEncoding = 'base64') {
this.secretKey = Buffer.from(encryptSecret, encoding);
}
// 加密函数
encrypt(text: string) {