refactors base58 encoding and decoding