Prev: The session problems with a citrix terminal
Next: Session Vars loaded from MSSQL Query drop, those loaded from MYSQL Query stick
From: Nathan Rixham on 16 Sep 2010 08:59 Gary wrote: > Can anyone tell me what the equivalent to the following command line > usage of openssl is, in php using the mcrypt_* functions, please: > ,---- > | openssl enc -e -aes-256-cbc -k <some key> ... > `---- > > TIA. > > I tried > ,---- > | $iv = mcrypt_create_iv(mcrypt_get_block_size(MCRYPT_RIJNDAEL_256, > | MCRYPT_MODE_CBC), > | MCRYPT_DEV_RANDOM); > | $encryptedData = mcrypt_cbc(MCRYPT_RIJNDAEL_256 > | ,$passphrase > | ,$data > | ,MCRYPT_ENCRYPT > | ,$iv); > `---- use MCRYPT_RIJNDAEL_128 use an iv that's 32 bytes long (not 16)
From: Nathan Rixham on 16 Sep 2010 11:05
Gary wrote: > Nathan Rixham wrote: >> Gary wrote: >>> Can anyone tell me what the equivalent to the following command line >>> usage of openssl is, in php using the mcrypt_* functions, please: >>> ,---- >>> | openssl enc -e -aes-256-cbc -k <some key> ... >>> `---- >>> >>> TIA. >>> >>> I tried >>> ,---- >>> | $iv = mcrypt_create_iv(mcrypt_get_block_size(MCRYPT_RIJNDAEL_256, >>> | MCRYPT_MODE_CBC), >>> | MCRYPT_DEV_RANDOM); >>> | $encryptedData = mcrypt_cbc(MCRYPT_RIJNDAEL_256 >>> | ,$passphrase >>> | ,$data >>> | ,MCRYPT_ENCRYPT >>> | ,$iv); >>> `---- >> use MCRYPT_RIJNDAEL_128 > > Err.. why, if you don't mind me asking? > because MCRYPT_RIJNDAEL_128 is the implementation of AES and if you use a 16 bit key you get AES 128, a 32 bit key and you get AES 256 :) after a quick google for "php aes 256", I'd point you to this: http://www.chilkatsoft.com/p/php_aes.asp which explains all |