1
0
Fork 0
forked from fun/fun

Some echo()/print() fixes. (0.37.12)

This commit is contained in:
Johannes Findeisen 2025-12-13 02:24:23 +01:00
commit b16a42a4a7
6 changed files with 36 additions and 6 deletions

View file

@ -17,12 +17,17 @@
* hex-encoded as a string of length 2*len (since each byte -> two hex chars).
*/
#include <hex.fun>
print("--- random_number(len) demo ---")
len_bytes = 16
hexstr = random_number(len_bytes)
print("Requested bytes: " + to_string(len_bytes))
print("Hex string: " + hexstr)
print("Hex bytes array: " + to_string(hex_to_bytes(hexstr)))
echo("Hex dump to bytes: ")
print(hex_to_bytes(hexstr))
print("Hex length (should be 2*bytes = 32): " + to_string(len(hexstr)))
// Zero length returns empty string
@ -36,7 +41,9 @@ print("32 bytes -> " + to_string(len(hex64)) + " hex chars")
/* Possible output:
--- random_number(len) demo ---
Requested bytes: 16
Hex string: d5f12eb93b71e78cc803aa802e76e3b4
Hex string: 8497373c7fb52c6cb7f1e1fda5bb6a60
Hex bytes array: [array n=16]
Hex dump to bytes: [132, 151, 55, 60, 127, 181, 44, 108, 183, 241, 225, 253, 165, 187, 106, 96]
Hex length (should be 2*bytes = 32): 32
Empty (0 bytes) -> length: 0 value:
32 bytes -> 64 hex chars