Skip to content

Instantly share code, notes, and snippets.

@rochellelewis
Created March 27, 2017 04:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rochellelewis/35c72c0c774476d4c7e86f282dc5175d to your computer and use it in GitHub Desktop.
Save rochellelewis/35c72c0c774476d4c7e86f282dc5175d to your computer and use it in GitHub Desktop.
Demo of simple password hashing in PHP.
<?php
$pass = "password123";
$activationToken = bin2hex(random_bytes(16));
$salt = bin2hex(random_bytes(16));
$hash = hash_pbkdf2("sha512", $pass, $salt, 262144);
echo "The following values are good for SALT and ACTIVATION that are CHAR(32) data, and HASH that is CHAR(128) data.";
echo "password: " . $pass . "\n\n";
echo "activation token" . $activationToken . "\n\n";
echo "salt: " . $salt . "\n\n";
echo "password hash: " . $hash . "\n\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment