'How can I convert an Openssl command to decrypt .ts files into javascript code?
The file is encrypted using AES 128 CBC
Key in HEX:
B20782CBC32A7843E7691D55950C9A6A
IV in HEX:
43A6D967D5C17290D98322F5C8F6660B
Command Openssl that I want to convert (this command work):
openssl aes-128-cbc -d -in file.ts -out decrypt_file.ts -nosalt -iv 43A6D967D5C17290D98322F5C8F6660B -K B20782CBC32A7843E7691D55950C9A6A
My nodejs code (the output file is created but the conversion is incorrect):
var crypto = require('crypto');
var fs = require('fs');
let cipher_name = 'aes-128-cbc';
let iv = Buffer.from('43A6D967D5C17290D98322F5C8F6660B', 'hex');
let key = Buffer.from('B20782CBC32A7843E7691D55950C9A6A', 'hex');
let decoder = crypto.createDecipheriv(cipher_name, key, iv);
let text_crypt = fs.readFileSync('file.ts');
let chunks = [];
chunks.push(decoder.update(text_crypt, 'binary'));
chunks.push(decoder.final('binary'));
fs.writeFileSync('decrypt_file.ts', chunks.join('', 'binary'));
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
