Calculate the SHA-1 hash of the string "Hello" in PHP

Description

The following code shows how to calculate the SHA-1 hash of the string "Hello".

Example


/*from  ww  w .  ja  v a  2 s.com*/
<?php
    $str = "Hello";
    echo sha1($str);

    $str = "Hello";
    echo "The string: ".$str."<br>";
    echo "TRUE - Raw 20 character binary format: ".sha1($str, TRUE)."<br>";
    echo "FALSE - 40 character hex number: ".sha1($str)."<br>";
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Development »




Environment
Error
Hash
Include
Locale
Math
Network
Output
Reflection
PHP Regular Expressions