This rule is deprecated; use {rule:php:S4790} instead.

## Why is this an issue?

The MD5 algorithm and its successor, SHA-1, are no longer considered secure, because it is too easy to create hash collisions with them. That is, it takes too little computational effort to come up with a different input that produces the same MD5 or SHA-1 hash, and using the new, same-hash value gives an attacker the same access as if he had the originally-hashed value. This applies as well to the other Message-Digest algorithms: MD2, MD4, MD6, HAVAL-128, HMAC-MD5, DSA (which uses SHA-1), RIPEMD, RIPEMD-128, RIPEMD-160, HMACRIPEMD160.

Consider using safer alternatives, such as SHA-256, SHA-512 or SHA-3.

### Noncompliant code example

    $password = ...

    if (md5($password) === '1f3870be274f6c49b3e31a0c6728957f') { // Noncompliant; md5() hashing algorithm is not secure for password management
       [...]
    }

    if (sha1($password) === 'd0be2dc421be4fcd0172e5afceea3970e2f3d940') { // Noncompliant; sha1() hashing algorithm is not secure for password management
       [...]
    }

## Resources

- OWASP - Top 10 2017 Category A6 - Security Misconfiguration
- CWE - CWE-328 - Reversible One-Way Hash
- CWE - CWE-327 - Use of a Broken or Risky Cryptographic Algorithm
- SHAttered - The first concrete collision attack against SHA-1.