Base58 and most importantly Base58Check encoder/decoder for Pharo.
Base58 is mostly used in cryptocurrencies such as Bitcoin, but it was also used by Flickr. This encoder supports both alphabets.
No Baseline yet, a single package with no external dependencies including one test class.
Gofer it
repository: (MCRepository fromUrl: 'github://eMaringolo/pharo-base58/src');
package: 'Base58-Core';
load.
Encodes aByteArray to a Base58 string
Decodes to a ByteArray a Base58 encoded string
Encodes aByteArray using Base58Check with anInteger as version byte.
Same as previous with 0
as version byte.
Decodes a Base58Check encoded string, returns a Base58CheckWrapper
instance, that responds to version
, payload
and checksum
.
Converting the RIPEMD160 20 byte hash 010966776006953D5567439E5E39F86A0D273BEE
to a Bitcoin P2PKH address
| encoder |
encoder := Base58Encoder new.
(encoder encodeCheck: ByteArray readHexFrom: '010966776006953D5567439E5E39F86A0D273BEE')
"'16UwLL9Risc3QfPqBUvKofHmBQ7wMtjvM'"
| encoder |
encoder := Base58Encoder new.
(encoder decode: 'BJBRbygJtzBfp4gjJG2iqL') asString
"'Satoshi Nakamoto'"
See the test suite Base58EncoderTest
for more examples.
Base58 converts leading zero bytes in the input to '1' characters in the output,
so an hex string 0001
or #[0 0 0 1]
ByteArray will be encoded as 1112
,
so leading zeros in the input are significant.