Skip to content

Instantly share code, notes, and snippets.

@ObiajuluM
Forked from dangell7/main.py
Last active April 17, 2022 08:53
Show Gist options
  • Save ObiajuluM/653a7d765b5e624744c9fdbdbf500d85 to your computer and use it in GitHub Desktop.
Save ObiajuluM/653a7d765b5e624744c9fdbdbf500d85 to your computer and use it in GitHub Desktop.
XRPL (Bytes -> Hex <- Bytes)
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:
bytes_string = bytes.fromhex(str(hex)).decode('utf-8')
return bytes_string.rstrip('\x00')
return hex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment