Showing posts with label PHP sha1. Show all posts
Showing posts with label PHP sha1. Show all posts

Monday, 29 September 2014

sha1 in PHP

PHP sha1 function is used to calculate the sha1 hash of a string.

Syntax:

sha1(string,raw)
string : Required. The input string to be calculated

raw : Optional. Defines hex or binary output format : 
             TRUE –returns in  Raw binary format with length 20 character.
             FALSE – Default. 40 character hex number

Example:

<?php
$str_name = "Good Morning";
echo sha1($str_name)."<br />";
echo sha1($str_name, TRUE)."<br />";
?>
Output will be:
06e336231466d0b0573a05cbca7813444afb5b29 
ã6#fаW:ËÊxDJû[)