1--TEST-- 2Test hash_pbkdf2() function : basic functionality 3--SKIPIF-- 4<?php extension_loaded('hash') or die('skip: hash extension not loaded.'); ?> 5--FILE-- 6<?php 7 8/* Prototype : string hash_hmac(string $algo, string $data, string $key [, int $length = 0 [, bool $raw_output = false]]) 9 * Description: Generate a keyed hash value using the HMAC method 10 * Source code: ext/hash/hash.c 11 * Alias to functions: 12*/ 13 14echo "*** Testing hash_pbkdf2() : basic functionality ***\n"; 15 16echo "sha1: " . hash_pbkdf2('sha1', 'password', 'salt', 1, 20)."\n"; 17echo "sha1(no length): " . hash_pbkdf2('sha1', 'password', 'salt', 1)."\n"; 18echo "sha1(raw): " . bin2hex(hash_pbkdf2('sha1', 'password', 'salt', 1, 20, TRUE))."\n"; 19echo "sha1(rounds): " . hash_pbkdf2('sha1', 'passwordPASSWORDpassword', 'saltSALTsaltSALTsaltSALTsaltSALTsalt', 4096, 25)."\n"; 20echo "sha1(rounds)(raw): " . bin2hex(hash_pbkdf2('sha1', 'passwordPASSWORDpassword', 'saltSALTsaltSALTsaltSALTsaltSALTsalt', 4096, 25, TRUE))."\n"; 21echo "sha256: " . hash_pbkdf2('sha256', 'password', 'salt', 1, 20)."\n"; 22echo "sha256(no length): " . hash_pbkdf2('sha256', 'password', 'salt', 1)."\n"; 23echo "sha256(raw): " . bin2hex(hash_pbkdf2('sha256', 'password', 'salt', 1, 20, TRUE))."\n"; 24echo "sha256(rounds): " . hash_pbkdf2('sha256', 'passwordPASSWORDpassword', 'saltSALTsaltSALTsaltSALTsaltSALTsalt', 4096, 40)."\n"; 25echo "sha256(rounds)(raw): " . bin2hex(hash_pbkdf2('sha256', 'passwordPASSWORDpassword', 'saltSALTsaltSALTsaltSALTsaltSALTsalt', 4096, 40, TRUE))."\n"; 26 27?> 28===Done=== 29--EXPECT-- 30*** Testing hash_pbkdf2() : basic functionality *** 31sha1: 0c60c80f961f0e71f3a9 32sha1(no length): 0c60c80f961f0e71f3a9b524af6012062fe037a6 33sha1(raw): 0c60c80f961f0e71f3a9b524af6012062fe037a6 34sha1(rounds): 3d2eec4fe41c849b80c8d8366 35sha1(rounds)(raw): 3d2eec4fe41c849b80c8d83662c0e44a8b291a964cf2f07038 36sha256: 120fb6cffcf8b32c43e7 37sha256(no length): 120fb6cffcf8b32c43e7225256c4f837a86548c92ccc35480805987cb70be17b 38sha256(raw): 120fb6cffcf8b32c43e7225256c4f837a86548c9 39sha256(rounds): 348c89dbcbd32b2f32d814b8116e84cf2b17347e 40sha256(rounds)(raw): 348c89dbcbd32b2f32d814b8116e84cf2b17347ebc1800181c4e2a1fb8dd53e1c635518c7dac47e9 41===Done=== 42