feat: use external aes lib

This commit is contained in:
Vlad Stan
2022-08-12 10:25:54 +03:00
parent f24149050d
commit 3f71df7829
2 changed files with 121 additions and 20 deletions
+26 -1
View File
@@ -254,8 +254,33 @@ async function decryptMessage(key, ciphertext) {
iv
},
key,
new Uint8Array(ciphertext)
ciphertext
)
return decrypted
}
async function decryptMessage2(key, encryptedBytes) {
iv = new Uint8Array([
0x00,
0x01,
0x02,
0x03,
0x04,
0x05,
0x06,
0x07,
0x08,
0x09,
0x0a,
0x0b,
0x0c,
0x0d,
0x0e,
0x0f
])
const aesCbc = new aesjs.ModeOfOperation.cbc(key, iv)
const decryptedBytes = aesCbc.decrypt(encryptedBytes)
console.log('### decryptedBytes', decryptedBytes)
return decryptedBytes
}