Last active
June 16, 2018 18:47
-
-
Save steveosoule/f27332e5c0671bc84c81a8ed3e9d3696 to your computer and use it in GitHub Desktop.
Miva - Hash Plain-Text Password to Match Encrypted Customer Password
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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