PHP sha1() Function

PHP sha1() Function is used to generate the SHA-1 hash of a string. The sha1() function uses the US Secure Hash Algorithm 1.

Syntax :

sha1(string,binary) ;

Parameter Values,

string : Required. It  takes a string as input.
binary : Optional. Specifies hex or binary output format.
            TRUE - Raw 20 character binary format
            FALSE - Default. 40 character hex number

Let's see below example to understand sha1() function.

 

Example :

<?php
$hex = sha1("aryatechno");
echo "<br>It returns 40 character hex number :".$hex; // display SHA-1 hash of a string

$binary= sha1("aryatechno",TRUE); // binary parameter is TRUE
echo "<br>It returns Raw 20 character binary format :".$binary; // display SHA-1 hash of a string

?>

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

82741