1--TEST-- 2Compatibility of password_hash (libargon2 / openssl) 3--EXTENSIONS-- 4openssl 5sodium 6--SKIPIF-- 7<?php 8if (PASSWORD_ARGON2_PROVIDER != "standard") { 9 echo "skip - libargon2 not available"; 10} 11 12if (!function_exists('openssl_password_hash')) { 13 echo "skip - No crypto_pwhash_str_verify"; 14} 15?> 16--FILE-- 17<?php 18 19echo 'Argon2 provider: '; 20var_dump(PASSWORD_ARGON2_PROVIDER); 21 22foreach([1, 2] as $mem) { 23 foreach([1, 2] as $time) { 24 $opts = [ 25 'memory_cost' => PASSWORD_ARGON2_DEFAULT_MEMORY_COST / $mem, 26 'time_cost' => PASSWORD_ARGON2_DEFAULT_TIME_COST / $time, 27 'threads' => PASSWORD_ARGON2_DEFAULT_THREADS, 28 ]; 29 $algo = 'argon2id'; 30 $pass = "secret$mem$time$algo"; 31 32 /* hash with libargon2 / verify with openssl */ 33 $hash = password_hash($pass, PASSWORD_ARGON2ID, $opts); 34 var_dump(openssl_password_verify($algo, $pass, $hash)); 35 36 /* hash with openssl / verify with libargon2 */ 37 $hash = openssl_password_hash($algo, $pass, $opts); 38 var_dump(password_verify($pass, $hash)); 39 } 40} 41?> 42--EXPECT-- 43Argon2 provider: string(8) "standard" 44bool(true) 45bool(true) 46bool(true) 47bool(true) 48bool(true) 49bool(true) 50bool(true) 51bool(true) 52 53