From 656242be52adc1742784335d6b9cd3402e92b6b7 Mon Sep 17 00:00:00 2001 From: luying Date: Tue, 4 Apr 2023 13:18:53 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20fix(=E6=B4=BB=E5=8A=A8):=20?= =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E5=85=AC=E4=BC=97=E5=8F=B7=E5=8F=A3=E4=BB=A4?= =?UTF-8?q?=E5=8A=A0=E5=AF=86=E5=8E=BB=E9=99=A4=E8=A1=A5=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shared/pubUtils/util.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/shared/pubUtils/util.ts b/shared/pubUtils/util.ts index aace6f771..bcada41ff 100644 --- a/shared/pubUtils/util.ts +++ b/shared/pubUtils/util.ts @@ -51,23 +51,22 @@ export function aesDecryptcfb(data, key, iv) { export function aes128Encrypt(input: string, key = '') { const cipher = crypto.createCipheriv('aes-128-ecb', key, null); - let crypted = cipher.update(pkcs5_pad(input, 16), 'utf8', 'base64'); + let crypted = cipher.update(input, 'utf8', 'base64'); crypted += cipher.final('base64'); - console.log('****aesEncryptcfb', 'input: ', input, 'crypted:', crypted) + console.log('****aesEncryptecb', 'input: ', `"${input}"`, 'crypted:', `"${crypted}"`) return crypted; } -function pkcs5_pad(text: string, blocksize: number) { - const pad = blocksize - (text.length % blocksize); - return text + String.fromCharCode(pad).repeat(pad); -} +// function pkcs5_pad(text: string, blocksize: number) { +// const pad = blocksize - (text.length % blocksize); +// return text + String.fromCharCode(pad).repeat(pad); +// } export function aes128Decrypt(data: string, key = '') { const decipher = crypto.createDecipheriv('aes-128-ecb', key, null); let crypted = decipher.update(data, 'base64', 'utf8'); crypted += decipher.final('utf8'); const padding = crypted.charCodeAt(crypted.length - 1); - // console.log('****aesEncryptcfb', data, crypted) return crypted.slice(0, -padding);; }