I'm trying to decode a code using nodejs and crypto. I tried to decode it using this website to get the result that I want. But I think I'm buffering the key the wrong way. How can I decode where the key is vague?
const decipher = crypto.createDecipheriv("aes-128-ecb", Buffer.from('4d52c7125cdd4e55868e190e0ec1c846', 'hex'), null);
const decryptedSecret = decipher.update('8E874DE6CE510690F8E2866FF5C8EA18A6B7CEF9DD4048C4EF6C7FFE678C6FD3', 'hex', 'hex') decipher.final("hex");
console.log("final: ", decryptedSecret);
My expected result per the website is VeHo8t9C1DNxLsaU
. I also tried to reverse encode it but still didnt get any result wanted.
CodePudding user response:
The algorithm is AES-256-ECB with PKCS7 padding, the key 4d52...c846
is to be UTF-8 encoded, as output encoding UTF-8 is to be applied:
const decipher = crypto.createDecipheriv('aes-256-ecb', Buffer.from('4d52c7125cdd4e55868e190e0ec1c846', 'utf8'), null);
const decryptedSecret = decipher.update('8E874DE6CE510690F8E2866FF5C8EA18A6B7CEF9DD4048C4EF6C7FFE678C6FD3', 'hex', 'utf8') decipher.final('utf8');
console.log("final: ", decryptedSecret); // final: VeHo8t9C1DNxLsaU