Anyone having trouble with the hash functions?
It says it's installed as of 5.1.2, but... its not on any of my systems [debian and freebsd based].
Any idea how to install functionality without the PECL module?
All i need is a function that will encrypt a string using the cram-md5 hash [ to be able to validate courier-imap with my custom login database ]
Cram MD5
Moderator: General Moderators
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
This was taken from the PEAR SMTP auth library and adapted for my needs.
Code: Select all
function _authGenerateCRAM_MD5_Response($password, $challenge)
{
if (strlen($password) > 64)
$password = pack('H32', md5($password));
if (strlen($password) < 64)
$password = str_pad($password, 64, chr(0));
$k_ipad = substr($password, 0, 64) ^ str_repeat(chr(0x36), 64);
$k_opad = substr($password, 0, 64) ^ str_repeat(chr(0x5C), 64);
$inner = pack('H32', md5($k_ipad.$challenge));
$digest = md5($k_opad.$inner);
return $digest;
}