Skip to content

eMaringolo/pharo-base58

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

pharo-base58

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.

Installation

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.

API

#encode: aByteArray

Encodes aByteArray to a Base58 string

#decode: aString

Decodes to a ByteArray a Base58 encoded string

encodeCheck: aByteArray version: anInteger

Encodes aByteArray using Base58Check with anInteger as version byte.

encodeCheck: aByteArray

Same as previous with 0 as version byte.

decodeCheck: aString

Decodes a Base58Check encoded string, returns a Base58CheckWrapper instance, that responds to version, payload and checksum.

Examples

Generating a Bitcoin address

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.

Remarks

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.

About

Base58/Base58Check encoder and decoder for Pharo

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published