hash_init()


string hash_init(string $algo)

Description

hash_init() initializes an incremental hashing context

※ available F/W version : all

Parameters

Return values

Returns a hasing context for use with hash_update(), hash_final().

Example

<?php
$data1 = "abcdefg";
$data2 = "hijklmn";

$context = hash_init("md5");
hash_update($context, $data1);
hash_update($context, $data2);
$hash_value = hash_final($context, true);

hexdump($hash_value);
// OUTPUT: 0000  08 45 a5 97 2c d9 ad 4a  46 ba d6 6f 12 53 58 1f  |.E..,..JF..o.SX.|
?>

See also

hash() / hash_update() / hash_final() / hash_hmac()

Remarks

hash_init() is identical to PHP group’s hash_init function. However, it supports only "md5", "sha1" and "sha256" algorithms and it doesn’t support the second and the third parameters.

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