How secure is this hash? (Php)

function oneWayEncrypt($string) { 
    $salt = md5($string."yHuJ@8&6%4#%([@d-]"); 
    $salt2 = md5($string."@!#&+-)jU@[yT$@%"); 

    $string = hash('sha512',"$salt$string$salt2"); 

    return $string; 
} 
+3
source share
3 answers

Using SHA-512 is a good idea to get a cryptographically strong hash, but your choice of salt does not add extra protection. In particular, salt is only good if its value is random and cannot be predicted in advance. This allows an attacker to pre-compute a table of known hashes with which you can try to attack your database. If the salt is known, then the attacker can simply precompute the hash value table with a solid salt relationship.

, . , () , SHA-512 . , .

, , , , . , , , , , . , , , , (, 128 ), , . SHA-512, ( " " ), .

+15

?

? - , .

cookie? - HMAC, .

, , , . . .

, -, , , . .

, , SHA-512 , . Preimage Attacks 41-Step SHA-256 46-Step SHA-512 . , (PDF), , , SHA-256 SHA-512, , , SHA-256 SHA-512.

+4

SHA-512 - , : SHA-512 154 /. -, , , bcrypt, .

In addition, use a random and unique salt for each hash operation and store it with the hash so that you can play back the hash for comparison.

+2
source

Source: https://habr.com/ru/post/1796611/


All Articles