vendredi 25 mars 2022

Decrypting AES-256-CBC with Nodejs to PHP Laravel (5.8)

I have instance key and iv. I want to decrypt data to json with NodeJS programming like this

const crypto = require("crypto")
export const decryption = (body: string) => {
const key = process.env.SECRET_TOKEN; // if (!key) throw new Error("Key is missing");
const iv = process.env.SECRET_IV;
if (!iv) throw new Error("Key is missing");
let encryptedText = Buffer.from(body, "hex");
let decipher = crypto.createDecipheriv("aes-256-cbc", Buffer.from(key, "hex"), Buffer.from(iv, "hex"));
let decrypted = decipher.update(encryptedText);
decrypted = Buffer.concat([decrypted, decipher.final()]);
return decrypted.toString(); }

I tried to use openssl_decrypt but not working. Please you help me convert NodeJS programming to PHP (Laravel 5.8).

Thank in advance.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/NseqAd7
via IFTTT

Aucun commentaire:

Enregistrer un commentaire