Created
March 6, 2014 06:12
-
-
Save XertroV/9383437 to your computer and use it in GitHub Desktop.
Turn any <20 bytes into a bitcoin address
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
#!/usr/bin/python | |
from hashlib import sha256 | |
import sys | |
from pycoin.encoding import b2a_base58 | |
def hashme(m): | |
return sha256(m).digest() | |
if len(sys.argv) == 1: | |
inputBytes = raw_input("Type your message > ") | |
else: | |
inputBytes = sys.argv[1] | |
print repr(inputBytes) | |
if len(inputBytes) > 20: | |
print 'error: too many bytes' | |
sys.exit() | |
while len(inputBytes) != 20: | |
inputBytes += '2e'.decode('hex') | |
inputBytes = '00'.decode('hex') + inputBytes | |
checksum = hashme(hashme(inputBytes))[:4] | |
bytesAddr = inputBytes + checksum | |
address = b2a_base58(bytesAddr) | |
print address | |
#print bytesAddr.encode('hex') | |
#print bytesAddr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment