restructured base58 encoder