Skip to content

Instantly share code, notes, and snippets.

@huggre
Last active March 17, 2020 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save huggre/991259a162c3c3941daa577a8a24c276 to your computer and use it in GitHub Desktop.
Save huggre/991259a162c3c3941daa577a8a24c276 to your computer and use it in GitHub Desktop.
Helper for converting an IOTA address to a C++ hex array
# Imports the textrwap library
from textwrap import wrap
# Replace with your own IOTA payment address
sample = 'NYZBHOVSMDWWABXSACAJTTWJOQRPVVAWLBSFQVSJSWWBJJLLSQKNZFC9XCRPQSVFQZPBJCJRANNPVMMEZQJRQSVVGZ'
# Create a list with 4 characters in each element
mylist = wrap(sample,4)
result = ''
# Convert each element in the list to hex separated by ,
for i in mylist:
result=result + '0x' + i.encode("utf-8").hex() + ','
# Remove last , from string
result=result[:-1]
# Append the curly brackets
result = '{' + result + '}'
# Print the resulting string
print(result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment