Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save steveosoule/f27332e5c0671bc84c81a8ed3e9d3696 to your computer and use it in GitHub Desktop.
Save steveosoule/f27332e5c0671bc84c81a8ed3e9d3696 to your computer and use it in GitHub Desktop.
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" );
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment