Skip to content

Instantly share code, notes, and snippets.

@evd0kim
Created April 15, 2019 14:37
Show Gist options
  • Save evd0kim/b52a41c91be2a41860c0798da2e81347 to your computer and use it in GitHub Desktop.
Save evd0kim/b52a41c91be2a41860c0798da2e81347 to your computer and use it in GitHub Desktop.
Simple script for using together python-mnemonic and Moonbase OneRNG
import sys
import time
from mnemonic import Mnemonic
if __name__ == '__main__':
if len(sys.argv) < 2:
print("Suggested usage: rng-mnemonic <keys number> ")
sys.exit(0)
try:
n = int(sys.argv[1])
except ValueError:
print("Keys number must be integer")
#OneRNG provides instructions about generator availability and activity
#other way to ensure RNG is working is to call cat /dev/random > /dev/null in bash
print("Checking generator. Look at the LED")
time.sleep(1.)
with open('/dev/random', 'rb') as rnd:
rnd.read(1024*16)
time.sleep(1.)
#real generation
with open('/dev/random', 'rb') as rnd:
for i in range(0, n):
print("\nKey: {}".format(i))
m = Mnemonic("english")
print("Mnemonic: {}".format(m.to_mnemonic(rnd.read(32))))
print("Completed")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment