View Single Post
  #12  
Old 29th April 2010, 13:56
mike_p mike_p is offline
Senior Member
 
Join Date: Mar 2010
Location: Surrey, England
Posts: 140
Thanks: 9
Thanked 28 Times in 17 Posts
Default

For future reference the salt should only be 12 characters including the '$1$'
and the final '$' is optional.

To confirm it I tested with a simple little php script:

Code:
<?
$salt = '$1$12345678abcd$';
$res = crypt('whatever',$salt) ;

echo "salt   = $salt\n";
echo "result = $res\n";

$salt = '$1$12345678$';
$res = crypt('whatever',$salt) ;

echo "salt   = $salt\n";
echo "result = $res\n";
?>
---------------- 
result....
----------------
salt   = $1$12345678abcd$
result = $1$12345678$OF2XnrBgffDDN5xlSzPhb.
salt   = $1$12345678
result = $1$12345678$OF2XnrBgffDDN5xlSzPhb.
ie the extra four characters were simply ignored.

There is a good description of the MD5 implemenation of crypt in the man page for 'crypt' in the GNU EXTENSION section.
Reply With Quote