nupp.codec.hex
Bytes as hexadecimal.
const hex = require("nupp.codec.hex")
print(hex.encode("Nu")) -- 4e75
print(hex.decode("4E75")) -- Nuencode writes lowercase; decode reads either case, and wants nothing around the digits -- no whitespace, no 0x.
Module contents
Functions
| Function | Kind | Description |
|---|---|---|
decode | function | Decodes hexadecimal without whitespace or a prefix. |
encode | function | Encodes raw bytes as lowercase hexadecimal. |
Functions#
decodefunction#
function decode(text: string): string?, string?Decodes hexadecimal without whitespace or a prefix.
Arguments
| Name | Type | Description |
|---|---|---|
text | string |
Returns
| Type | Description |
|---|---|
string? | raw bytes, or nil and a reason |
string? |
encodefunction#
function encode(bytes: string): stringEncodes raw bytes as lowercase hexadecimal.
Arguments
| Name | Type | Description |
|---|---|---|
bytes | string |
Returns
| Type | Description |
|---|---|
string |