sha1
(PHP 4 >= 4.3.0, PHP 5, PECL hash:1.1-1.3)
sha1 — Calcola l'hash sha1 di una stringa
Descrizione
string sha1
( string $str
[, bool $raw_output
] )
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()