I am trying to get nodejs to run the equivalent of
openssl enc -aes-192-cbc -k secret -P -md sha1
As described here: https://www.ibm.com/support/knowledgecenter/en/SSLVY3_9.7.0/com.ibm.einstall.doc/topics/t_einstall_GenerateAESkey.html
That is, generate a key/iv pair that will be compatible with other tools that expect AES CBC.
I could try to actually run openssl as a shell command, but I'm hoping there is a more node native way of doing so.
Could I generate 2 random hex of the correct length? One for iv and one for key?
I am adding my own answer, using new NodeJS APIs available in v10:
let passphrase = "some passphrase"
let iv = crypto.randomBytes(16); // Initialization vector.
let salt = crypto.randomBytes(16);
let key = crypto.scryptSync(passphrase, salt, 16);
This generates a key and iv pair, compatible with AES-128-CBC
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With