File: openssl_pbkdf2_basic.phpt

package info (click to toggle)
php8.4 8.4.11-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 208,108 kB
  • sloc: ansic: 1,060,628; php: 35,345; sh: 11,866; cpp: 7,201; pascal: 4,913; javascript: 3,091; asm: 2,810; yacc: 2,411; makefile: 689; xml: 446; python: 301; awk: 148
file content (28 lines) | stat: -rw-r--r-- 985 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
--TEST--
openssl_pbkdf2() tests
--EXTENSIONS--
openssl
--SKIPIF--
<?php if (!function_exists("openssl_pbkdf2")) print "skip"; ?>
--FILE--
<?php
// official test vectors
var_dump(bin2hex(openssl_pbkdf2('password', 'salt', 20, 1)));
var_dump(bin2hex(openssl_pbkdf2('password', 'salt', 20, 2)));
var_dump(bin2hex(openssl_pbkdf2('password', 'salt', 20, 4096)));

/* really slow but should be:
string(40) "eefe3d61cd4da4e4e9945b3d6ba2158c2634e984"
var_dump(bin2hex(openssl_pbkdf2('password', 'salt', 20, 16777216)));
*/

var_dump(bin2hex(openssl_pbkdf2('passwordPASSWORDpassword', 'saltSALTsaltSALTsaltSALTsaltSALTsalt', 25, 4096)));
var_dump(bin2hex(openssl_pbkdf2("pass\0word", "sa\0lt", 16, 4096)));

?>
--EXPECT--
string(40) "0c60c80f961f0e71f3a9b524af6012062fe037a6"
string(40) "ea6c014dc72d6f8ccd1ed92ace1d41f0d8de8957"
string(40) "4b007901b765489abead49d926f721d065a429c1"
string(50) "3d2eec4fe41c849b80c8d83662c0e44a8b291a964cf2f07038"
string(32) "56fa6aa75548099dcc37d7f03425e0c3"