Skip to content

Instantly share code, notes, and snippets.

@ochaloup
Last active May 22, 2023 06:45
Show Gist options
  • Save ochaloup/8ecfd13ea84d4ac8603569716b1b34fb to your computer and use it in GitHub Desktop.
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
#!~/.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