sha1

(PHP 4 >= 4.3.0, PHP 5, PHP 7, PHP 8)

sha1Calcola l'hash sha1 di una stringa

Descrizione

sha1(string $str, bool $raw_output = ?): string

Calcola l'hash sha1 di str usando il » US Secure Hash Algorithm 1, e restituisce l'hash. L'hash è un numero esadecimale di 40 caratteri. Se il parametro opzionale raw_output è impostato a true, allora l'hash sha1 è restituito in formato binario con una lunghezza di 20 caratteri.

Nota: Il parametro opzionale raw_output è stato aggiunto in PHP 5.0.0 ed ha come default false

Example #1 Esempio di uso di sha1()

<?php
$str
= 'apple';

if (
sha1($str) === 'd0be2dc421be4fcd0172e5afceea3970e2f3d940') {
echo
"Would you like a green or red apple?";
exit;
}
?>

Vedere anche sha1_file(), crc32() e md5()