PHP hash() function
This function is used to convert data in hash form. This is used for security purpose to convert messages, username, password in hash format.
Syntax
hash(algorithmname, string, rowoutput);
First parameter is the algorithm name like sha1, md5, sha2, sha512. Second parameter is the string that will be hashed. The rowoutput is optional, if it is set to TRUE, then it returns raw binary data and is set to FALSE then returns lowercase exits.
Example
<?php
$username = 'myuser';
$secret_msg = 'abc123';
$uname = hash(md5, $username);
$msg = hash(sha1, $secret_msg);
echo $uname.'<br/>';
echo $msg.'<br/>';
?>
Output -
5d5a582e5adf896ed6e1474c700b481a6367c48dd193d56ea7b0baad25b19455e529f5ee
Related PHP Functions
PHP array_reverse() functionPHP array_diff() function
PHP array_key_exists() function
PHP array_push() function
PHP array_search() function
PHP class_exists() function
PHP curl_setopt() function
PHP die() function
PHP dirname() function
PHP each() function
PHP explode() function
PHP file_exists() function
PHP function_exists() function
PHP getenv() function
PHP is_readable() function
PHP ksort() function
PHP mkdir() function
PHP ob_start() function
PHP parse_url() function
PHP str_repeat() function
PHP substr() function