Answer the question
In order to leave comments, you need to log in
How effective is it?
Hello. I will make a reservation right away that I stumbled upon the function by accident.
$str = hash_hmac(HASH, $str, HASH_SECRET1);
for ($i = 0; $i < 100; $i++) {
$str = md5($str);
}
class security {
function salt() {
$chars = "qazxswedcvfrtgbnhyujmkiolp1234567890QAZXSWEDCVFRTGBNHYUJMKIOLP";
$max = HASH_SALT;
$size = StrLen($chars) - 1;
$salt = null;
while ($max--) {
$salt.=$chars[rand(0, $size)];
}
return $salt;
}
public function NewHash5($str) {
$salt = self::salt();
$str = hash_hmac(HASH, HASH_SECRET3 . $str . $salt, HASH_SECRET1);
for ($i = 0; $i < 100; $i++) {
$str = hash('sha1', $str);
}
for ($i = 0; $i < HASH_REKURS; $i++) {
$str = hash('whirlpool', HASH_SECRET3 . $str . $salt.HASH_SECRET2);
}
for ($i = 0; $i < 10; $i++) {
$str = hash('haval128,3', $str);
}
for ($i = 0; $i < 10; $i++) {
$str = hash('adler32', $str);
}
$return['hash'] = HASH_SECRET2 . $str;
$return['salt'] = $salt;
return $return;
}
}
substr(microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"], 0, 10)
Answer the question
In order to leave comments, you need to log in
bcrypt to the rescue.
// EDIT
Extremely inefficient.
// EDIT2
Generate a random string (instead of your salt function, adjust the length):
bin2hex(openssl_random_pseudo_bytes(21));
I'm not a cryptologist, but I think this is a crazy overhead. Better make the salting algorithm smarter.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question