diff options
Diffstat (limited to 'ext/sodium/tests/crypto_shorthash.phpt')
-rw-r--r-- | ext/sodium/tests/crypto_shorthash.phpt | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/ext/sodium/tests/crypto_shorthash.phpt b/ext/sodium/tests/crypto_shorthash.phpt new file mode 100644 index 0000000000..3398def06e --- /dev/null +++ b/ext/sodium/tests/crypto_shorthash.phpt @@ -0,0 +1,28 @@ +--TEST-- +Check for libsodium shorthash +--SKIPIF-- +<?php if (!extension_loaded("sodium")) print "skip"; ?> +--FILE-- +<?php +$m1 = 'message'; +$k1 = '0123456789ABCDEF'; +$h1 = sodium_crypto_shorthash($m1, $k1); +echo bin2hex($h1) . "\n"; +$k2 = '0123456789abcdef'; +$h2 = sodium_crypto_shorthash($m1, $k2); +echo bin2hex($h2) . "\n"; +$m2 = 'msg'; +$h3 = sodium_crypto_shorthash($m2, $k2); +echo bin2hex($h3) . "\n"; + +try { + sodium_crypto_shorthash($m1, $k1 . $k2); +} catch (SodiumException $ex) { + var_dump(true); +} +?> +--EXPECT-- +e0ad6fdbf8b9a191 +c667b37af201a2d9 +d27fa3fc70b45b72 +bool(true) |