Created
September 8, 2015 17:37
-
-
Save Zegnat/b29bba931a80f1e33877 to your computer and use it in GitHub Desktop.
Replacement getkirby/toolkit/lib/password.php using PHP 5.5 password_* functions and paragonie/password_lock inspired SHA512 pre-hashing to support passwords with more than 72 characters.
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 | |
class Password { | |
static public function hash($plaintext) { | |
return password_hash(base64_encode(hash('sha512', $plaintext, true)), PASSWORD_DEFAULT); | |
} | |
static public function isHash($hash) { | |
$info = password_get_info($hash); | |
return $info['algo'] !== 0; | |
} | |
static public function check($plaintext, $hash) { | |
return password_verify(base64_encode(hash('sha512', $plaintext, true)), $hash); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment