Decrypt from AES-ECB ciphertext created with php/mcrypt using node.js -


i have encrypted message using mcrypt_rijndael_128, ecb mode, , base64, i've tried decrypting using crypto(https://www.npmjs.com/package/crypto) following code:

var text = ''; var decipher = crypto.createdecipheriv("aes-128-ecb","somekeyherewithlength32ooooooooo", ''); text += decipher.update(data, "base64"); text += decipher.final(); 

the error i've been getting is: invalid key length 32.

what should length of key be? when attempt use 16 instead error thrown is: 'typeerror: error:06065064:digital envelope routines:evp_decryptfinal_ex:bad decrypt'

if client requires use ecb key of length 32, how can make case valid?

aes subset of rijndael fixed block size 128 bit whereas rijndael supports block sizes of 128, 192 , 256 bit. 128 in mcrypt_rijndael_128 means block size. 128 in aes-128-ecb on other hand means key size. both aes , rijndael support key sizes of 128, 192 , 256 bit.

if have 32 character key , key not hex-encoded reach 32 characters possible want aes-256-ecb.

keep in mind key encoding might different 1 in php might need parse key buffer specific encoding.


also, please don't use ecb mode. insecure. should use @ least cbc mode random iv. since iv not need secret, can send along ciphertext prefix example. need slice off before decryption.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -