What do we mean by hash functions in PHP?


A hash function is any function that can be used to map data of arbitrary size to data of a fixed size. The values returned by a hash function are called hash values, hash codes, digests, or simply hashes.

Syntax

string hash( string $algo , string $data [, bool $raw_output = FALSE ] )

Parameters

algo

Name of selected hashing algorithm (like "md5", "sha256", "haval160,4", etc..)

data

Message to be hashed.

raw_output

When setting to TRUE, outputs raw binary data. FALSE outputs lowercase hexits.

Example

<?php
   echo hash('sha256', 'Weelcome Tutorials Point');
?>

Output

dacbedc476c664e457b165580dd5eb491bc027c914504066c51f56b1116d56e0

Updated on: 29-Jun-2020

170 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements