hex
- Description:
- Provides methods for hexadecimal encoding and decoding. This namespace includes functions to convert strings to and from hexadecimal format, which is often used for data representation in computing. It is useful for encoding binary data as a readable string format, commonly used in cryptography and data transmission.
Methods
(static) decode(hexString) → {string}
- Description:
- Decodes a hexadecimal string back into a UTF-8 string.
Example
const decoded = hex.decode('48656c6c6f2c20576f726c6421');
console.log(decoded); // Outputs: Hello, World!
Parameters:
Name | Type | Description |
---|---|---|
hexString |
string | The hexadecimal string to decode. |
Returns:
The original UTF-8 string.
- Type
- string
(static) encode(inputString) → {string}
- Description:
- Encodes a string into hexadecimal format.
Example
const encoded = hex.encode('Hello, World!');
console.log(encoded); // Outputs: 48656c6c6f2c20576f726c6421
Parameters:
Name | Type | Description |
---|---|---|
inputString |
string | The string to encode. |
Returns:
The hexadecimal encoded string.
- Type
- string