Forked from steveosoule/miva-hash-plain-text-password-to-match-encrypted-customer-password.php
Created
June 16, 2018 18:47
-
-
Save freeroute/2e7561f3fe7c0da680b00b3c61204db8 to your computer and use it in GitHub Desktop.
Miva - Hash Plain-Text Password to Match Encrypted Customer Password
This file contains hidden or 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