Zum Inhalt springen

Weak hash algorithm (ARCH7111)

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

Key php.security.weak-hash · Severity error · Category security · CWE CWE-328

MD5 and SHA-1 are cryptographically broken and prone to collisions. Using them for security purposes such as integrity or signing defeats the protection; SHA-256 or stronger should be used.

<?php
$digest = md5($payload);
$sig = sha1($secret . $payload);
<?php
$digest = hash('sha256', $payload);
$sig = hash_hmac('sha256', $payload, $secret);

For security hashing use SHA-256 or stronger instead of MD5/SHA-1; for message authentication use hash_hmac().