keis / base58

Base58 and Base58Check implementation compatible with what is used by the bitcoin network.
MIT License
180 stars 59 forks source link

Doesn't work with echo #36

Closed pdelteil closed 5 years ago

pdelteil commented 5 years ago

I had this issue:

$ echo "23t3yhAuaMWSkzyg5bwpwkcbwDW4b1vT7hKetYNsiW1SrS7kEd2Mz9SCoGM6qQ9QZRTYJUsbxP4U2qnsre3cdjhDBW3rqrhxK5XC12yo1HvujG5envGAyMwf4HpnZ1Z5NWcKkMpERMDpsJ8EbrnqLBTRPxW5UfzZHcvKwayp1KxwSzzwZTb671eSVAZkND4FHJApU1kht88vqitjBHUPp5H" | base58 -d $ substring not found

But it works with printf:

$ printf "23t3yhAuaMWSkzyg5bwpwkcbwDW4b1vT7hKetYNsiW1SrS7kEd2Mz9SCoGM6qQ9QZRTYJUsbxP4U2qnsre3cdjhDBW3rqrhxK5XC12yo1HvujG5envGAyMwf4HpnZ1Z5NWcKkMpERMDpsJ8EbrnqLBTRPxW5UfzZHcvKwayp1KxwSzzwZTb671eSVAZkND4FHJApU1kht88vqitjBHUPp5H" | base58 -d $ 3167103626579990164481551900631455406227649498339870931463659678762007414973185848385145925751739606156366598497723358368426602431521721329611646179289862914

Why?

keis commented 5 years ago

Thanks for the report @pdelteil it's because of the newline that echo adds this is a regression in 1d17699. So rather than always stripping like what caused #24 it should only be done when decoding as it's not a valid character anyway.

I'll may look into this on the weekend but a PRs welcome if you're up for it

pdelteil commented 5 years ago

Hey @keis,

Thanks for your answer. I've found a way to solve it. I will send PR.

Have a good one.