note 47887 modified in function.mcrypt-encrypt by danbrown

From: Date: Wed, 06 May 2009 22:02:08 +0000
Subject: note 47887 modified in function.mcrypt-encrypt by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-154294@lists.php.net to get a copy of this message
Note that the key need to be a binary string--not a hex string. A 128-bit key would be 16 characters long, for example. Use the pack() function to quickly convert a hex string into the actual binary data: <?php $key_hex = '66e94bd4ef8a2c3b884cfa59ca342b2e'; $key_bin = pack('H*', $key_hex); $pt = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key_bin, $et, MCRYPT_MODE_ECB); ?> --was-- Note that the key need to be a binary string--not a hex string. A 128-bit key would be 16 characters long, for example. Use the pack() function to quickly convert a hex string into the actual binary data: $key_hex = '66e94bd4ef8a2c3b884cfa59ca342b2e'; $key_bin = pack('H*', $key_hex); $pt = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key_bin, $et, MCRYPT_MODE_ECB); http://php.net/manual/en/function.mcrypt-encrypt.php

« previous php.notes (#154294) next »