note 65315 added to function.mcrypt-cbc
| From: | php-general at lists dot php dot net | Date: | Fri, 28 Apr 2006 15:44:38 +0000 |
| Subject: | note 65315 added to function.mcrypt-cbc | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-109997@lists.php.net to get a copy of this message | ||
Here is a post similar to the one above, except this works for AES256
256 bit key and 128 bit block size... just make sure the $key variable is at least 48 characters
long
---- PERL ---
my $key = '12345678901234567890123456789012345678901234567890';
my $CC = '4007000000027';
# You need Crypt::Rijndael installed for this to work
use Crypt::CBC;
my $cipher = Crypt::CBC->new( {'key' => substr($key,0,32),
'cipher'=> 'Rijndael',
'iv' => substr($key,32,16),
'regenerate_key' => 0,
'padding' => 'null',
'prepend_iv' => 0
});
my $encrypted = $cipher->encrypt($CC);
print "encrypted : ".$encrypted."\n";
print "decrypted : ".$cipher->decrypt($encrypted)."\n";
--- PHP ---
$key = '123456789012345678901234567890123456789012345678901234567890';
$CC = '4007000000027';
$encrypted = mcrypt_cbc(MCRYPT_RIJNDAEL_128,substr($key,0,32)
,$CC,MCRYPT_ENCRYPT,substr($key,32,16));
$decrypted = mcrypt_cbc(MCRYPT_RIJNDAEL_128,substr($key,0,32)
,$encrypted,MCRYPT_DECRYPT,substr($key,32,16));
echo "encrypted : ".bin2hex($encrypted);
----
Server IP: 66.163.161.117
Probable Submitter: 65.162.166.20
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.mcrypt-cbc.php
Edit -- http://master.php.net/note/edit/65315
Del: integrated -- http://master.php.net/note/delete/65315/integrated
Del: useless -- http://master.php.net/note/delete/65315/useless
Del: bad code -- http://master.php.net/note/delete/65315/bad+code
Del: spam -- http://master.php.net/note/delete/65315/spam
Del: non-english -- http://master.php.net/note/delete/65315/non-english
Del: in docs -- http://master.php.net/note/delete/65315/in+docs
Del: other reasons-- http://master.php.net/note/delete/65315
Reject -- http://master.php.net/note/reject/65315
Search -- http://master.php.net/manage/user-notes.php