Last active
August 29, 2015 14:01
-
-
Save zerowebcorp/33fb2eb19d3517057b10 to your computer and use it in GitHub Desktop.
Simple functions to encode a password in PHP
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 | |
class Password_Hash | |
{ | |
public static function hash($password) | |
{ | |
return hash("sha512", $password); | |
} | |
public static function isValid($password, $hash) | |
{ | |
if (self::hash($password) === $hash) | |
return true; | |
} | |
} | |
$hash = Password_Hash::hash('vivek'); | |
if (Password_Hash::isValid('vivek', $hash)) | |
echo 'Authentication success'; | |
else | |
echo 'Authentication failed'; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment