Может кто-нибудь взглянуть на мой код и следующую ошибку? Я не могу найти решение после нескольких часов поиска.
const decrypt = (textBase64, keyBase64, ivBase64) => {
const algorithm = "AES-256-CBC";
const ivBuffer = Buffer.from(ivBase64, "base64");
const keyBuffer = Buffer.from(keyBase64, "base64");
const decipher = crypto.createDecipheriv(algorithm, keyBuffer, ivBuffer);
decipher.setAutoPadding(false);
let decrypted = decipher.update(textBase64, "base64", "utf8");
decrypted += decipher.final("utf8");
return decrypted;
};
const encryptedMessage =
"eVlXaWgxTWw1Wm1paStNckh0cy9IMFhjSnZTTzlBMm9BWnB3SS8vcjYyTT0=";
const key = "wu6eAo3MA4XM2G2vszNrppGJb+T/Wgv+TwUmOA6bAl8=";
const iv = Buffer.from(
"ORpU3E8fsbTP8drytjP9yDIq7DT9SmNIEUQIdKWV81NbpTi8",
"base64"
).slice(0, 16);
// the message comes from the bytes AFTER the IV - this is what you should decrypt
const message = Buffer.from(encryptedMessage, "base64").slice(16);
const result = decrypt(message, key, iv);
res.send("Decrypted: " + result);```