note 109490 added to function.mcrypt-cbc

From: Date: Sun, 22 Jul 2012 04:59:54 +0000
Subject: note 109490 added to function.mcrypt-cbc
Groups: php.notes 
Request: Send a blank email to php-notes+get-189349@lists.php.net to get a copy of this message
The PERL libraries have changed a little bit and getting PHP and PERL to mcrypt together can be confusing, so here is a current example; PHP === $string = 'Some Secret thing I want to encrypt'; $iv = '12345678'; $passphrase = '8chrsLng'; $encryptedString = encryptString($string, $passphrase, $iv); // Expect: 7DjnpOXG+FrUaOuc8x6vyrkk3atSiAf425ly5KpG7lOYgwouw2UATw== function encryptString($unencryptedText, $passphrase, $iv) { $enc = mcrypt_encrypt(MCRYPT_BLOWFISH, $passphrase, $unencryptedText, MCRYPT_MODE_CBC, $iv); return base64_encode($enc); } PERL ==== $encryptedString = '7DjnpOXG+FrUaOuc8x6vyrkk3atSiAf425ly5KpG7lOYgwouw2UATw=='; $iv = '12345678'; $passphrase = '8chrsLng'; $string = &decryptPhpEncrypted $encryptedString, $passphrase, $iv; # Expect: Some Secret thing I want to encrypt sub decryptPhpEncrypted() { my ($encryptedString, $passphrase, $iv) = @_; my $keysize = length($passphrase); use Crypt::CBC; $cipher = Crypt::CBC->new( {'key' => $encryptedString, 'cipher'=> 'Blowfish', 'iv' => $iv, 'keysize' => $keysize, 'regenerate_key' => 0, 'padding' => 'null', 'prepend_iv' => 0}); return $cipher->decrypt($encryptedString); } ---- Server IP: 69.147.83.197 Probable Submitter: 99.50.112.30 ---- Manual Page -- http://www.php.net/manual/en/function.mcrypt-cbc.php Edit -- https://master.php.net/note/edit/109490 Del: integrated -- https://master.php.net/note/delete/109490/integrated Del: useless -- https://master.php.net/note/delete/109490/useless Del: bad code -- https://master.php.net/note/delete/109490/bad+code Del: spam -- https://master.php.net/note/delete/109490/spam Del: non-english -- https://master.php.net/note/delete/109490/non-english Del: in docs -- https://master.php.net/note/delete/109490/in+docs Del: other reasons-- https://master.php.net/note/delete/109490 Reject -- https://master.php.net/note/reject/109490 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#189349) next »