xref: /PHP-8.0/ext/sodium/tests/crypto_hex.phpt (revision 5cfa26c1)
1--TEST--
2Check for libsodium bin2hex
3--SKIPIF--
4<?php if (!extension_loaded("sodium")) print "skip"; ?>
5--FILE--
6<?php
7$bin = random_bytes(random_int(1, 1000));
8$hex = sodium_bin2hex($bin);
9$phphex = bin2hex($bin);
10var_dump(strcasecmp($hex, $phphex));
11
12$bin2 = sodium_hex2bin($hex);
13var_dump($bin2 === $bin);
14
15$bin2 = sodium_hex2bin('[' . $hex .']', '[]');
16var_dump($bin2 === $bin);
17?>
18--EXPECT--
19int(0)
20bool(true)
21bool(true)
22