-
-
Save dangell7/6ef45b88d2123c7ef7b9a2f674d8e20f to your computer and use it in GitHub Desktop.
XRPL (Bytes -> Hex <- Bytes)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def symbol_to_hex(symbol: str = None) -> str: | |
"""symbol_to_hex.""" | |
if len(symbol) > 3: | |
bytes_string = bytes(str(symbol).encode('utf-8')) | |
return bytes_string.hex().upper().ljust(40, '0') | |
return symbol | |
def hex_to_symbol(hex: str = None) -> str: | |
"""hex_to_symbol.""" | |
if len(hex) > 3: | |
return bytes.fromhex(str(hex)).decode('utf-8') | |
return hex |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment