Created
July 3, 2013 19:35
-
-
Save lukas2511/5922009 to your computer and use it in GitHub Desktop.
froxlor makeCryptPassword wrapper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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