javascript - AES encrypt in .NET with zero padding and decrypt with Node.js -


i'm trying decrypt data nodejs.

this data created c# , aes-cbc-256 algorithm. keysize , blocksize 256 , padding zeropadding.

i cant' decrypt node.js, error is:

error: error:0606506d:digital envelope routines:evp_decryptfinal_ex:wrong final block length 

here javascript code:

decipher = crypto.createdecipheriv('aes-256-cbc', key, iv.slice(0, 16)); decrypted = decipher.update(encryptedpayloadbuffer, 'base64', 'ascii'); decrypted += decipher.final('ascii'); decipher = null;  return decrypted; 

i use library "crypto". read somewhere node.js decryption works pksc7 padding. true ? can't change in c# project, must find solution on node side.

can me please ?

edit: tried disable autopadding this:

decipher.setautopadding(false); //next line of code: //decrypted = decipher.update(encryptedpayloadbuffer, 'base64', 'ascii'); 

but received error:

error: error:0606508a:digital envelope routines:evp_decryptfinal_ex:data not multiple of block length 

there difference between aes , rijndael. both specify key sizes of 128, 192 , 256 bits, rijndael provides 3 block sizes: 128, 192 , 256 bits. aes rijndael fixed block size of 128 bit.

node.js uses openssl provide available ciphers (crypto.getciphers()). if there no rijndael implementation available version, can't use node.js' crypto module. you'll either need find node module implements rijndael or set block size 128 bit in c# code.


Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -