note 62873 added to function.mcrypt-cbc
| From: | eric at ez-llc dot com | Date: | Sat, 11 Mar 2006 17:38:54 +0000 |
| Subject: | note 62873 added to function.mcrypt-cbc | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-105275@lists.php.net to get a copy of this message | ||
I was able get php and perl to play together with blowfish using cipher block chaining. The
blowfish key needs to be atleast 8 chars (even though blowfish min is 8 bits, perl didn't like
keys smaller than 8 chars) and max 56. The iv must be exactly 8 chars and padding needs to be null
because php pads with nulls. Also, php needs libmcrypt >= 2.4.9 to be compatible with perl.
PERL
----
use Crypt::CBC;
$cipher = Crypt::CBC->new( {'key' => 'my secret key',
'cipher'=> 'Blowfish',
'iv' => '12345678',
'regenerate_key' => 0,
'padding' => 'null',
'prepend_iv' => 0
});
$cc = 'my secret text';
$encrypted = $cipher->encrypt($cc);
$decrypted = $cipher->decrypt($encrypted);
print "encrypted : ".$encrypted;
print "<br>";
print "decrypted : ".$decrypted;
PHP
---
$cc = 'my secret text';
$encrypted = mcrypt_cbc(MCRYPT_BLOWFISH,'my secret
key',$cc,MCRYPT_ENCRYPT,'12345678');
$decrypted = mcrypt_cbc(MCRYPT_BLOWFISH, 'my secret key', $encrypted,
MCRYPT_DECRYPT,'12345678');
echo "encrypted : ".$encrypted;
echo "<br>";
echo "decrypted : ".$decrypted;
----
Server IP: 216.194.113.175
Probable Submitter: 12.108.126.131
----
X-Spam-Status: No, hits=3.3 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER,
HTML_MESSAGE autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.mcrypt-cbc.php
Edit -- http://master.php.net/note/edit/62873
Del: integrated -- http://master.php.net/note/delete/62873/integrated
Del: useless -- http://master.php.net/note/delete/62873/useless
Del: bad code -- http://master.php.net/note/delete/62873/bad+code
Del: spam -- http://master.php.net/note/delete/62873/spam
Del: non-english -- http://master.php.net/note/delete/62873/non-english
Del: in docs -- http://master.php.net/note/delete/62873/in+docs
Del: other reasons-- http://master.php.net/note/delete/62873
Reject -- http://master.php.net/note/reject/62873
Search -- http://master.php.net/manage/user-notes.php