Last active
March 17, 2020 14:18
-
-
Save huggre/991259a162c3c3941daa577a8a24c276 to your computer and use it in GitHub Desktop.
Helper for converting an IOTA address to a C++ hex array
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
# 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