From:             [EMAIL PROTECTED]
Operating system: Linux
PHP version:      4.0.4pl1
PHP Bug Type:     Feature/Change Request
Bug description:  Non mhash binmd5() implementation in  pear/Crypt?HCEMD5.php

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 bug report at: http://bugs.php.net/?id=13189&edit=1


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to