Miva - Hash Plain-Text Password to Match Encrypted Customer Password
<?php
/* Split the password into component parts */
$encrypted = "PBKDF1:sha1:1000:gE2lydzFBG8=:+vynLWCYzSCRpdRqjNO3ke67Brw=";
$fields = explode( ":", $encrypted );
$iterations = $fields[ 2 ];
$salt = base64_decode( $fields[ 3 ] );
$encrypted = base64_decode( $fields[ 4 ] );
/* This is the password we are verifying */
$password = "wombat!";
/* This is PBKDF1 */
$password = $password . $salt;
for ( $i = 0; $i < $iterations; $i++ )
{
$password = sha1( $password, true );
}
/* Check the password */
if ( !strncmp( $password, $encrypted, strlen( $encrypted ) ) )
{
print "Password matches\n";
}
else
{
print( "Password does not match\n" );
}
?>