Author

Topic: Base58? (Read 881 times)

newbie
Activity: 38
Merit: 0
March 23, 2014, 09:48:08 AM
#6
Why do you need to convert bytes to base58 for addresses and wallet import format private keys? How can it be useful?


From the bitcoin wiki:

// Why base-58 instead of standard base-64 encoding?
// - Don't want 0OIl characters that look the same in some fonts and
//      could be used to create visually identical looking account numbers.
// - A string with non-alphanumeric characters is not as easily accepted as an account number.
// - E-mail usually won't line-break if there's no punctuation to break at.
// - Doubleclicking selects the whole number as one word if it's all alphanumeric.

newbie
Activity: 28
Merit: 0
March 22, 2014, 07:11:58 AM
#5
Why do you need to convert bytes to base58 for addresses and wallet import format private keys? How can it be useful?
sr. member
Activity: 350
Merit: 251
March 21, 2014, 04:24:45 AM
#4
http://we.lovebitco.in/paperwal.py

Has two functions o_b58():with bitcoin address checksum and b58encode():non checksum. You can use it as an import library. Since it makes a bitcoin address, everything library-wise that you need to make a paper wallet is obviously included.

https://bitcointalksearch.org/topic/ann-python-paper-wallet-generator-with-strong-randomness-361092
Perfect, thanks

Just in case anyone finds this question by googling and wants the solution:

Code:
def b58encode(v):
""" gavin bitcointool - encode v, which is a string of bytes, to base58.
"""
_b58chars = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
_b58base = len(_b58chars)

#(c style int->base256)
long_value = 0L
for (i, c) in enumerate(v[::-1]):
long_value += (256**i) * ord(c)
result = ''
while long_value >= _b58base:
div, mod = divmod(long_value, _b58base)
result = _b58chars[mod] + result
long_value = div
result = _b58chars[long_value] + result
zeropad = 0
for c in v:
if c == '\x00':
zeropad += 1
else:
break
return '1'*zeropad + result
legendary
Activity: 1512
Merit: 1036
March 21, 2014, 04:17:20 AM
#3
http://we.lovebitco.in/paperwal.py

Has two functions o_b58():with bitcoin address checksum and b58encode():non checksum. You can use it as an import library. Since it makes a bitcoin address, everything library-wise that you need to make a paper wallet is obviously included.

https://bitcointalksearch.org/topic/ann-python-paper-wallet-generator-with-strong-randomness-361092
legendary
Activity: 1106
Merit: 1016
090930
March 21, 2014, 03:29:09 AM
#2
I have some really tight code for this on my home PC. Will try to remember to post it this when I get a chance this weekend - that is, if nobody beats me to it. Smiley  There are literally dozens of implementations around.
If you can't wait, you can try digging through the Electrum and Armory repos.
sr. member
Activity: 350
Merit: 251
March 21, 2014, 02:24:31 AM
#1
Where can I find a Python function to convert bytes to base58 for addresses and wallet import format private keys?



The wiki only has what appears to be some kind of pseudocode.
Jump to: