Bug #13189 Updated: Non mhash binmd5() implementation in pear/Crypt?HCEMD5.php

From: Date: Sat, 19 Jan 2002 17:53:38 +0000
Subject: Bug #13189 Updated: Non mhash binmd5() implementation in pear/Crypt?HCEMD5.php
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-4003@lists.php.net to get a copy of this message
ID: 13189 Updated by: mj Reported By: plasma@projectplasma.com Status: Open Old Bug Type: Feature/Change Request Bug Type: PEAR related Operating System: Linux PHP Version: 4.0.4pl1 New Comment: Changing category to PEAR. Previous Comments: ------------------------------------------------------------------------ [2001-09-07 00:06:43] plasma@projectplasma.com If one does not have the mhash extension the HCEMD5.php script falls back to the following in the binmd5() method: return pack('H*', md5(pack('H*', preg_replace('|00$|', '', bin2hex($string))))); Which does not interoperate with the perl Crypt::HCE_MD5.pm unless one uses a 7 bit clean key 2. replacing the above line with: return pack('H*', md5($string)); Works much better. What problem was the original line trying to work around? Is this a problem with the perl implementation or the HCEMD5.php script? Thanks #!/usr/bin/perl -w # The following PERL script generates an HCE_MD5 encrypted # message that's format compatible with decodeMimeSelfRand() use Crypt::HCE_MD5; use MIME::Base64; $rand = int(1 + rand(32767)); $prand = pack('i*',$rand); # base64 encode key2 chomp( $mime_rand = encode_base64($prand) ); # create cipher object with key1 & key2 $cipher = Crypt::HCE_MD5->new("greatjustice", $prand); # encrypt & base64 encode $ciphertext = $cipher->hce_block_encode_mime("Hunka Bunka"); # emit Crypt_HCEMD5::decodeMimeSelfRand() compatible ciphertext print "$mimerand#$ciphertext\n"; ------------------------------------------------------------------------ Edit this bug report at http://bugs.php.net/?id=13189&edit=1

« previous php.pear.dev (#4003) next »