Last active
May 22, 2023 06:45
-
-
Save ochaloup/8ecfd13ea84d4ac8603569716b1b34fb to your computer and use it in GitHub Desktop.
Python script to convert base58 format string to binary uint8 array of decimal numbers
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
#!~/.pyenv/shims/python3 | |
# Usage: | |
# frombase58.py 11111111111111111111111111111111 | |
# Output: | |
# [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] | |
import base58 | |
import sys | |
if len(sys.argv) != 2: | |
print(f"Expecting argument of base58 string, not provided. Arguments: {sys.argv}") | |
exit(1) | |
string_key = sys.argv[1] | |
byte_array = base58.b58decode(string_key) | |
json_string = "[" + ",".join(map(lambda b: str(b), byte_array)) + "]" | |
print(json_string) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment