X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=testing%2FMCTXWeb%2Fpublic_html%2Fusers%2Fmodels%2Ffuncs.php;h=b1afc72946b023bb03228f487130be304ae9216e;hb=4d7acf83795a57a89150d27d21ac86dcb4c33804;hp=021f3a0539a1beb8f353173f4db9ffa33a97320b;hpb=bd5fabfeabdd16cf38642c8cfb2232aab495de31;p=matches%2FMCTX3420.git diff --git a/testing/MCTXWeb/public_html/users/models/funcs.php b/testing/MCTXWeb/public_html/users/models/funcs.php index 021f3a0..b1afc72 100644 --- a/testing/MCTXWeb/public_html/users/models/funcs.php +++ b/testing/MCTXWeb/public_html/users/models/funcs.php @@ -71,14 +71,23 @@ function generateHash($plainText, $salt = null) { if ($salt === null) { - $salt = substr(md5(uniqid(rand(), true)), 0, 25); + //$salt = substr(md5(uniqid(rand(), true)), 0, 25); // Original UserCake + $random = file_get_contents("/dev/urandom", false, null, 0, 25); // Get random number + $salt = '$6$'.bin2hex($random).'$'; // Make hex salt + } - else - { - $salt = substr($salt, 0, 25); - } - - return $salt . sha1($salt . $plainText); + //return $salt . sha1($salt . $plainText); // Original UserCake + return crypt($plainText, $salt); +} + +/** + * Generates a random password for emailing to new users. + * User should be asked to change the password. + */ +function generatePassword() +{ + $random = file_get_contents("/dev/urandom", false, null, 0, 25); + return bin2hex($random); } //Checks if an email is valid