What is the syntax of the MD5() function in php?
md5(string,raw)
Parameter | Description |
---|---|
string | Required. The string to be calculated |
raw | Optional. Specifies hex or binary output format:TRUE – Raw 16 character binary formatFALSE – Default. 32 character hex number |
examples of the MD5() function
Example 1. In this example, we calculate the MD5 hash of the string “Hello”.
<?php
$str = "Hello";
echo md5($str);
?>
Example 2. In this example, we print the result of md5().
<?php
$str = "Hello";
echo "The string: ".$str."<br>";
echo "TRUE - Raw 16 character binary format: ".md5($str, TRUE)."<br>";
echo "FALSE - 32 character hex number: ".md5($str)."<br>";
?>
Example 1. In this example,we print the result of md5() and then test it.
<?php
$str = "Hello";
echo md5($str);
if (md5($str) == "8b1a9953c4611296a827abf8c47804d7")
{
echo "<br>Hello world!";
exit;
}
?>