Created
October 10, 2012 08:18
-
-
Save JeremySkinner/3863991 to your computer and use it in GitHub Desktop.
Replicating .NET Password Hashing in PHP
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
// From http://gilbert.pellegrom.me/replicating-net-password-hashing-in-php/ | |
/* | |
* $password is the users password entered at login | |
* $hashed_password is the password from the database | |
* $password_salt is the salt from the database | |
*/ | |
$bytes = mb_convert_encoding($password, 'UTF-16LE'); | |
$salt = base64_decode($password_salt); | |
$password = base64_encode(sha1($salt . $bytes, true)); | |
if ($password == $hashed_password) return true; | |
else return false; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment