Skip to content

Instantly share code, notes, and snippets.

@zerowebcorp
Last active August 29, 2015 14:01
Show Gist options
  • Save zerowebcorp/33fb2eb19d3517057b10 to your computer and use it in GitHub Desktop.
Save zerowebcorp/33fb2eb19d3517057b10 to your computer and use it in GitHub Desktop.
Simple functions to encode a password in PHP
<?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