I want to convert wif as Base58 string to byte array.

Private key to WIF

printf 800C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D507A5B8D | xxd -r -p | base58


Now I want reverse this (WIF to private key), form 5HueCGU8rMjxEXxiPuD5BDku4MkFqeZyd4dZ1jvhTVqvbTLvyTJ to 800C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D507A5B8D

Im using that library https://github.com/keis/base58 But I can change or better if I can use only bash without extra library

full example https://en.bitcoin.it/wiki/Wallet_import_format

  • Are you looking for an alternative tool to decode base58 to hex?
    – James C.
    Jan 22 '19 at 13:29
  • no the alternative. with this tool I can't to base58 to hex, or I don't understand How can I that
    – monkeyUser
    Jan 22 '19 at 13:55

You need to use the decode flag -d:

printf "5HueCGU8rMjxEXxiPuD5BDku4MkFqeZyd4dZ1jvhTVqvbTLvyTJ" | base58 -c -d | xxd -p

To have xxd output all on one line, give it a large column number -c flag:

$ printf "5HueCGU8rMjxEXxiPuD5BDku4MkFqeZyd4dZ1jvhTVqvbTLvyTJ" | base58 -c -d | xxd -p -c 1000

If you really want the checksum included 507A5B8D (the last 4 bytes), omit the -c flag which denotes checksum encoding:

$ printf "5HueCGU8rMjxEXxiPuD5BDku4MkFqeZyd4dZ1jvhTVqvbTLvyTJ" | base58 -d | xxd -p -c 1000

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.