PHP : md5() function

PHP Script:

<?php
$str=”PHP TUTORS md5 FUNCTION EXAMPLE”;
echo md5($str);
?>

Output:

cb97a255c33139010701c7a68c05d689

Description:

PHP md5() function calculates the MD5 hash of a string.
This function returns the calculated MD5 hash on success, or FALSE on failure.
It can be used to store password in database as encrypted form [md5 hash].

PHP md5 function parameters:

1- String: String for which md5 hash is going to be calculated.
2- Bolean value [optional]:
TRUE is for Raw 16 character binary format.
FALSE is for 32 character hex number.
By default value is FALSE.

Pictorial Presentation

php-string-md5()

Example :

  1. <?php  
  2. $input_string = 'Good Morning';  
  3. echo 'Original string : '.$input_string.'<br>';  
  4. echo '16 bit binary format : '.md5($input_string, TRUE).'<br>';  
  5. echo '32 bit binary format : '.md5($input_string).'<br>';  
  6. ?>  

Output :

Original string : Good Morning
16 bit binary format : r y †” du?Û£¿ân
32 bit binary format : 72a079088694099d64753fdba3bfe26e
- See more at: http://www.w3resource.com/php/function-reference/md5.php#sthash.rqMmDF8D.dpuf

No comments:

Post a Comment