utilModule
Utility functions.
bin2hex and hex2bin convert between a binary string and its hexadecimal representation.Functions
| bin2hex (str) | Converts a binary string to its hexadecimal representation. |
| hex2bin (hex) | Converts a hexadecimal string to its binary representation. |
Functions in detail
- bin2hex (str)
-
Converts a binary string to its hexadecimal representation.
Parameters
- str string binary string to convert.
Returns
-
string
hexadecimal representation of the input, two lowercase digits per byte.
- hex2bin (hex)
-
Converts a hexadecimal string to its binary representation.
Parameters
- hex string hexadecimal string to convert, two digits per byte in either case.
Returns
-
string
binary representation of the input.
Raises
"invalid hexadecimal string"whenhexhas an odd length or a character that is not a hexadecimal digit.