You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following code returns an empty string (with no error) as the output from cipher.final('hex'):
constcrypto=require('crypto');// just use a zero buffer for the key and iv...constkey=Buffer.alloc(32);constiv=Buffer.alloc(16);constc=crypto.createCipheriv('aes-256-cbc',key,iv);// disable auto padding because we are encrypting a complete block length// - this is what appears to mess up cipher.final()// - commenting this out or setting setAutoPadding(true) works as expected.c.setAutoPadding(false);// encrypt the key (with itself!)c.update(key);constencdata=c.final('hex');// for clarity, stringify the result...console.log('encdata: '+JSON.stringify(encdata));// result should be: encdata: "67695e1f7859caf3cd14f3445b9e5f1b"// result is actually: encdata: ""
Commenting out the setAutoPadding(false) line returns the correct output.
The text was updated successfully, but these errors were encountered:
The following code returns an empty string (with no error) as the output from
cipher.final('hex'):
Commenting out the
setAutoPadding(false)
line returns the correct output.The text was updated successfully, but these errors were encountered: