hash()


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

Description

hash() generates a hash value. (message digest)

※ available F/W version : all

Parameters

Return values

Returns a string containing the calculated message digest as lowercase hexits unless $raw_output is set to TRUE, in that case, the raw binary representation of the message digest is returned.

Example

<?php
$data = "abcdefghijklmn";

$hash_value1 = hash("md5", $data, true);
$hash_value2 = hash("md5", $data, false);
hexdump($hash_value1);  
// OUTPUT: 0000  08 45 a5 97 2c d9 ad 4a  46 ba d6 6f 12 53 58 1f  |.E..,..JF..o.SX.|
hexdump($hash_value2);  
// OUTPUT: 
// 0000  30 38 34 35 61 35 39 37  32 63 64 39 61 64 34 61  |0845a5972cd9ad4a|
// 0010  34 36 62 61 64 36 36 66  31 32 35 33 35 38 31 66  |46bad66f1253581f|
?>

See also

hash_init() / hash_update() / hash_final() / hash_hmac()

Remarks

hash() is identical to PHP group’s hash function. However, it supports only "md5", "sha1" and "sha256" algorithms.

※ "sha256" algorithm is only available on the firmware version 1.3.1 and later versions.