hash_pbkdf2()


bool hash_pbkdf2(string $algo, string $password, string $salt, int $iterations [ , int $length = 0 [ , bool $raw_output = false ] ] )

Description

hash_pbkdf2() generates a PBKDF2 key derivation of a supplied password

※ available F/W version : all

Parameters

Return values

Returns a string containing the derived key as lowercase hexits unless $raw_output is set to TRUE, in which case the raw binary representation of the derived key is returned.

Example

<?php
$passphrase = "0123456789";
$ssid = "ssid_test";

$psk = hash_pbkdf2("sha1", $passphrase, $ssid, 4096, 32, true);

hexdump($psk);
// OUTPUT
// 0000  43 e7 47 9c 66 51 60 dd  35 a8 f9 a5 86 2e a9 de  |C.G.fQ`.5.......|
// 0010  47 c3 9e 64 b5 1a 75 36  61 aa 32 3d 5f e2 cc 38  |G..d..u6a.2=_..8|
?>

See also

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

Remarks

hash_pbkdf2() is identical to PHP group’s hash_pbkdf2 function, but it supports only "md5", "sha1" and "sha256" algorithms. This function is very used to calculate a PSK for wireless LAN security.

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