NOVINKA: Najžiadanejšie rekvalifikačné kurzy teraz s 50% zľavou + kurz AI ZADARMO. Nečakaj, táto ponuka dlho nevydrží! Zisti viac:

PHP - sha1

Trieda

Koreň \ Bez triedy

Metóda - sha1

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

The sha1() function is used for calculating the sha1 hash of a string.

Warning: It's not recommended to use this function to hash passwords since it's easy to crack. For this purpose use the password_hash() function.

Procedurálne

  • function sha1 (string $str, bool $raw_output = false) : string

Parametre

NázovDátový typPredvolená hodnotaPopis
$strstring

The string to compute the sha1 hash from.

$raw_outputbool false

If the $raw_output is set to true, the sha1() function returns the raw binary format with the length of 20 bytes. Returns a 40-characters long hexadecimal number instead.

Mávratovej hodnoty

Vracia: string

Returns the hashed string as a 40-character long hexadecimal number.

Príklady

<?php
echo sha1('test'); // hexadecimal format: a94a8fe5ccb19ba61c4c0873d391e987982fbbd3
echo '<br>';
echo sha1('test', true);  // raw binary format

Súvisiace manuály

      • function crypt (string $str, string $salt) : string
      • function hash (string $algo, string $data, bool $raw_output = false) : string
      • function password_hash (string $password, integer $algo, array $options) : string
      Aktivity