A question about aes128 encryption for novice node

how do you write the following code in node?

const hash = crypto.createHash( "MD5" )
hash.update( aesKey )
const aesKeySignStr = hash.digest()
const iv = Math.random().toString( 36 ).substr( 2 )

const cipher = crypto.createCipher( "aes-128-cbc", aesKeySignStr, iv )
console.log( JSON.stringify( this.params ) );
let crypted = cipher.update( JSON.stringify( this.params ), "utf8", "hex" )
crypted += cipher.final( "hex" )

Please help me.

Mar.10,2021

results are different. Then print out the values in each process and have a look. There are only two reasons for the difference. 1. The algorithm is different, 2. The initial value is different


node doesn't quite understand, but I guess it's like this
because both the initial vector and the secret key have to be consistent with the size of the chunk, that is to say, if you use cbc-128, the size of both is 16 bytes
, but your code is obviously not like this

.
Menu