How to use sha1 in PHP
In this article I will explain how the sha1() function can be used in PHP.
sha1() function in PHP
- The sha1() function is used to calculate the SHA-1 hash of a string.
- The sha1() function uses the US Secure Hash Algorithm 1.
- The sha1() function returns the calculated SHA-1 hash on success.
- The sha1() function returns FALSE on failure.
Syntax
Parameter
- string string is required parameter. it is calculated to be string.
-
raw raw is optional parameter. it specify hex or binary output format:
- TRUE - it is represent raw 20 character binary format.
- FALSE - this is the default value. it is represent 40 character hex number.
Example
The following example show to how the sha1() function can be used in PHP.
<html>
<body>
<h3 style="color: blueviolet;">sha1() function example in PHP</h3>
<?php
$str = 'C-sharpcorner';
echo "c- sharpcorner SHA-1 hash code is : <br/>".sha1($str);
?>
</body>
</html>
|
Output
You may also want to read these related articles here
Ask Your Question
Got a programming related question? You may want to post your question here