Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ariankordi/0c55ba955696629221f1b0c80f971643 to your computer and use it in GitHub Desktop.
Save ariankordi/0c55ba955696629221f1b0c80f971643 to your computer and use it in GitHub Desktop.
<?php
# gen
$reqpsd = 'hello';
$salt = substr(strtr(base64_encode(openssl_random_pseudo_bytes(22)),'+','.'),0,22);
$hash = hash_pbkdf2('sha512', $reqpsd, $salt, 1000, 50).':'.$salt;
# /gen
# check
$passwd = 'hello';
$va = explode(':',$hash);
if(hash_pbkdf2('sha512',$passwd,$va[1],1000,50) == $va[0]) {
// success
print 'YES'; } else {
// unsuccess
print 'I don\'t think so..';
}
# /check
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment