xref: /PHP-8.2/ext/sodium/tests/crypto_hex.phpt (revision 6c9a0566)
1--TEST--
2Check for libsodium bin2hex
3--EXTENSIONS--
4sodium
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