Skip to content

Instantly share code, notes, and snippets.

@ozrabal
Created November 12, 2020 21:06
Show Gist options
  • Save ozrabal/09631879f1ed60a72dde03747adaf849 to your computer and use it in GitHub Desktop.
Save ozrabal/09631879f1ed60a72dde03747adaf849 to your computer and use it in GitHub Desktop.
Symfony fos user password
<?php
$salt = base_convert(sha1(uniqid(mt_rand(), true)), 16, 36);
echo "Salt used: " . $salt ."<br/>";
echo "<br/>";
$password = 'new_password';
$salted = $password.'{'.$salt.'}';
$digest = hash('sha512', $salted, true);
for ($i=1; $i<5000; $i++) {
$digest = hash('sha512', $digest.$salted, true);
}
$encodedPassword = base64_encode($digest);
echo "Password used: " . $password ."<br/>";
echo "<br/>";
echo "Encrypted Password: " . $encodedPassword ."<br/>";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment