diff options
author | Remi Collet <remi@remirepo.net> | 2024-09-13 10:13:12 +0200 |
---|---|---|
committer | Remi Collet <remi@php.net> | 2024-09-13 10:13:12 +0200 |
commit | ef4627a6a618b460cbbea109e3e0522c891be72c (patch) | |
tree | 466a4678a4c18d4a636f3375f4b72e3045cde437 /tests | |
parent | 5bca3985ce597abd2db703e0944160a8f73dd84a (diff) |
More bindings (function missing in php)
- add crypt_gensalt(?string $salt = null, int $count = 0): ?string {}
- add crypt_preferred_method(): ?string {}
- add crypt_checksalt(string $salt): int {}
and bump version to 1.1.0-dev (new functions)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/crypt_checksalt.phpt | 12 | ||||
-rw-r--r-- | tests/crypt_gensalt.phpt | 25 | ||||
-rw-r--r-- | tests/crypt_preferred_method.phpt | 9 | ||||
-rw-r--r-- | tests/password_compat.phpt | 22 |
4 files changed, 68 insertions, 0 deletions
diff --git a/tests/crypt_checksalt.phpt b/tests/crypt_checksalt.phpt new file mode 100644 index 0000000..4fbd8bf --- /dev/null +++ b/tests/crypt_checksalt.phpt @@ -0,0 +1,12 @@ +--TEST-- +Test crypt_checksalt +--FILE-- +<?php +var_dump(crypt_checksalt(crypt_gensalt(XPASS_CRYPT_STD_DES)) === CRYPT_SALT_METHOD_LEGACY); +var_dump(crypt_checksalt(crypt_gensalt()) === CRYPT_SALT_OK); +var_dump(crypt_checksalt("!not_a_valid_hash") === CRYPT_SALT_INVALID); +?> +--EXPECT-- +bool(true) +bool(true) +bool(true) diff --git a/tests/crypt_gensalt.phpt b/tests/crypt_gensalt.phpt new file mode 100644 index 0000000..b838a04 --- /dev/null +++ b/tests/crypt_gensalt.phpt @@ -0,0 +1,25 @@ +--TEST-- +Test crypt_gensalt +--FILE-- +<?php +var_dump(crypt_gensalt(XPASS_CRYPT_STD_DES)); +var_dump(crypt_gensalt(XPASS_CRYPT_EXT_DES)); +var_dump(crypt_gensalt(XPASS_CRYPT_MD5)); +var_dump(crypt_gensalt(XPASS_CRYPT_BLOWFISH)); +var_dump(crypt_gensalt(XPASS_CRYPT_SHA256)); +var_dump(crypt_gensalt(XPASS_CRYPT_SHA512)); +var_dump(crypt_gensalt(XPASS_CRYPT_SCRYPT)); +var_dump(crypt_gensalt(XPASS_CRYPT_GOST_YESCRYPT)); +var_dump(crypt_gensalt(XPASS_CRYPT_YESCRYPT)); + +?> +--EXPECTF-- +string(2) "%s" +string(9) "_%s" +string(11) "$1$%s" +string(29) "$2y$%s" +string(19) "$5$%s" +string(19) "$6$%s" +string(36) "$7$%s" +string(30) "$gy$%s" +string(29) "$y$j%s" diff --git a/tests/crypt_preferred_method.phpt b/tests/crypt_preferred_method.phpt new file mode 100644 index 0000000..f222639 --- /dev/null +++ b/tests/crypt_preferred_method.phpt @@ -0,0 +1,9 @@ +--TEST-- +Test crypt_preferred_method +--FILE-- +<?php +var_dump(crypt_preferred_method()); +?> +--EXPECTF-- +string(%d) "$%s$" + diff --git a/tests/password_compat.phpt b/tests/password_compat.phpt new file mode 100644 index 0000000..3dd6ad2 --- /dev/null +++ b/tests/password_compat.phpt @@ -0,0 +1,22 @@ +--TEST-- +Test crypt compatibility with password_hash +--FILE-- +<?php +$secret = 'mysecret'; + +/* generate with password_hash, check with both */ +$h = password_hash($secret, PASSWORD_BCRYPT); +var_dump($h, password_verify($secret, $h), $h===crypt($secret, $h)); + +/* generate with crypt, check with both */ +$h = crypt($secret, crypt_gensalt(XPASS_CRYPT_BLOWFISH)); +var_dump($h, password_verify($secret, $h), $h===crypt($secret, $h)); +?> +--EXPECTF-- +string(60) "$2y$%s$%s" +bool(true) +bool(true) +string(60) "$2y$%s$%s" +bool(true) +bool(true) + |