1--TEST--
2Basic features of password_hash
3--EXTENSIONS--
4openssl
5--SKIPIF--
6<?php
7if (!function_exists('openssl_password_hash')) {
8    echo "skip - No openssl_password_hash";
9}
10?>
11--FILE--
12<?php
13
14echo 'Argon2 provider: ';
15var_dump(PASSWORD_ARGON2_PROVIDER);
16
17foreach([1, 2] as $mem) {
18    foreach([1, 2] as $time) {
19        $opts = [
20            'memory_cost' => PASSWORD_ARGON2_DEFAULT_MEMORY_COST / $mem,
21            'time_cost'   => PASSWORD_ARGON2_DEFAULT_TIME_COST / $time,
22            'threads'     => PASSWORD_ARGON2_DEFAULT_THREADS,
23        ];
24        foreach(['argon2i', 'argon2id'] as $algo) {
25            $pass = "secret$mem$time$algo";
26            $hash = openssl_password_hash($algo, $pass, $opts);
27            var_dump(openssl_password_verify($algo, $pass, $hash));
28        }
29    }
30}
31?>
32--EXPECTF--
33Argon2 provider: string(%d) "%s"
34bool(true)
35bool(true)
36bool(true)
37bool(true)
38bool(true)
39bool(true)
40bool(true)
41bool(true)
42
43