Skip to content

Instantly share code, notes, and snippets.

@lukas2511
Created July 3, 2013 19:35
Show Gist options
  • Save lukas2511/5922009 to your computer and use it in GitHub Desktop.
Save lukas2511/5922009 to your computer and use it in GitHub Desktop.
froxlor makeCryptPassword wrapper
<?php
function generatePassword()
{
global $db, $settings;
return substr(md5(uniqid(microtime(), 1)), 24, 10);
}
function makeCryptPassword ($password, $type = 0)
{
switch($type)
{
case 0:
$cryptPassword = crypt($password);
break;
case 1:
$cryptPassword = crypt($password, '$1$' . generatePassword(). generatePassword());
break;
case 2:
$cryptPassword = crypt($password, '$2a$' . generatePassword(). generatePassword());
break;
case 3:
$cryptPassword = crypt($password, '$5$' . generatePassword(). generatePassword());
break;
case 4:
$cryptPassword = crypt($password, '$6$' . generatePassword(). generatePassword());
break;
default:
$cryptPassword = crypt($password);
break;
}
return ($cryptPassword);
}
echo "Password: ";
system('stty -echo');
$password = trim(fgets(STDIN));
system('stty echo');
echo "\n";
echo makeCryptPassword($password)."\n";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment