Added some more HEX (hex_to_dec()) Fun. (0.3714)
This commit is contained in:
parent
d2fca3275a
commit
9577f26e23
6 changed files with 131 additions and 11 deletions
|
|
@ -23,12 +23,20 @@ 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("Requested bytes:")
|
||||
print(to_string(len_bytes))
|
||||
print("Hex string:")
|
||||
print(hexstr)
|
||||
print("Hex bytes array:")
|
||||
print(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)))
|
||||
print("Hex as decimal (first 4 bytes):")
|
||||
print(to_string(hex_to_dec(substr(hexstr, 0, 8))))
|
||||
print("Hex as decimal (all bytes):")
|
||||
print(to_string(hex_to_dec(hexstr)))
|
||||
print("Hex length (should be 2*bytes = 32):")
|
||||
print(to_string(len(hexstr)))
|
||||
|
||||
// Zero length returns empty string
|
||||
empty = random_number(0)
|
||||
|
|
@ -40,11 +48,19 @@ print("32 bytes -> " + to_string(len(hex64)) + " hex chars")
|
|||
|
||||
/* Possible output:
|
||||
--- random_number(len) demo ---
|
||||
Requested bytes: 16
|
||||
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
|
||||
Requested bytes:
|
||||
16
|
||||
Hex string:
|
||||
50a76f143d67ce173962cd2eea5a86a4
|
||||
Hex bytes array:
|
||||
[array n=16]
|
||||
Hex dump to bytes:[80, 167, 111, 20, 61, 103, 206, 23, 57, 98, 205, 46, 234, 90, 134, 164]
|
||||
Hex as decimal (first 4 bytes):
|
||||
1353150228
|
||||
Hex as decimal (all bytes):
|
||||
4135093009263527588
|
||||
Hex length (should be 2*bytes = 32):
|
||||
32
|
||||
Empty (0 bytes) -> length: 0 value:
|
||||
32 bytes -> 64 hex chars
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue