Skip to content

Instantly share code, notes, and snippets.

@legomolina
Created December 2, 2017 00:48
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 legomolina/8c42b24b3950c41802f74a9a896e8ef2 to your computer and use it in GitHub Desktop.
Save legomolina/8c42b24b3950c41802f74a9a896e8ef2 to your computer and use it in GitHub Desktop.
Simple snippet to create a hashed password via php command line
<?php
if(count($argv) <= 1) {
print "Usage: php -f password.php mypassword [cost = 10]\n\n";
exit();
}
$password = $argv[1];
$cost = (count($argv) > 2) ? $argv[2] : 10;
$encPass = password_hash($password, PASSWORD_BCRYPT, array("cost" => $cost));
print "$encPass\n\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment