PHP: md5() function
Description
The md5() function is used to calculate the md5 hash (the hash as a 32-character hexadecimal number ) of a string.
Version:
(PHP 4 and above)
Syntax:
md5(input_string, raw_output)
Parameter:
Name | Description | Required / Optional |
Type |
---|---|---|---|
input_string | The input string. | Required | Float |
raw_output | Refers hex or binary output format, Returns raw 16-bit binary format if raw_output sets TRUE and return 32-bit hex format for setting FALSE (default). | Optional | Boolean |
Return value:
Returns the hash as a 32-character hexadecimal number.
Value Type: String.
Pictorial Presentation
Example:
<?php
$input_string = 'Good Morning';
echo 'Original string : '.$input_string.'<br>';
echo '16 bit binary format : '.md5($input_string, TRUE).'<br>';
echo '32 bit binary format : '.md5($input_string).'<br>';
?>
Output:
Original string : Good Morning 16 bit binary format : r y†” du?Û£¿ân 32 bit binary format : 72a079088694099d64753fdba3bfe26e
View the example in the browser
See also
PHP: Tips of the Day
To use the constant simply use its name:
Example:
if (EARTH_IS_FLAT) { print "Earth is flat"; } print APP_ENV_UPPERCASE;
Output:
or if you don't know the name of the constant in advance, use the constant function:
// this code is equivalent to the above code $const1 = "EARTH_IS_FLAT"; $const2 = "APP_ENV_UPPERCASE"; if (constant($const1)) { print "Earth is flat"; } print constant($const2);
Output:
- Weekly Trends
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join
- JavaScript functions Exercises
- Python Tutorial
- Python Array Exercises
- SQL Cross Join
- C# Sharp Array Exercises
We are closing our Disqus commenting system for some maintenanace issues. You may write to us at reach[at]yahoo[dot]com or visit us at Facebook