I was following the tutorial here : https://hackernoon.com/how-to-generate-bitcoin-addresses-technical-address-generation-explanation-rus3z9e

i imported base58 to my python project :

import base58

I tried to convert the private key at the tutorial into the base58 version

privatekey = "a4f228d49910e8ecb53ba6f23f33fbfd2bad442e902ea20b8cf89c473237bf9f"

# expected : C6t2iJ7AXA2X1KQVnqw3r7NKtKaERdLnaGmbDZNqxXjk
privatekey_base58 = base58.b58encode(privatekey)

But it didn't give me the expected value like in the tutorial , instead it gives me this enter image description here

How do i properly encode a string to base58 and decode base58 to original string ?


Use b58encode_check instead of non-check version and convert your hex to binary before passing it to the library.

  • And how do i decode base58 string ? Should i turn the string to binary too before decoding ? Oct 10 '21 at 12:04
  • No, but to decode convert the decode result to hex because it'll be in binary
    – MCCCS
    Oct 10 '21 at 12:23
  • help it doesnt work , i tried base58.b58encode_check(bin(int("0x000c2c910a661178ef63e276dd0e239883b862f58cc3c0439f", 16))) but it doesnt gives 127NVqnjf8gB9BFAW2dnQeM6wqmy1gbGtv like in the tutorial Oct 11 '21 at 2:34
  • Does this give you any inspiration stackoverflow.com/a/23565829 ?
    – MCCCS
    Oct 11 '21 at 6:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.