Decodes the given base58 string into the original data bytes.
Decodes the given base58 string into the original data bytes.
the base58-encoded string to decode
the decoded data bytes
Decodes the given base58 string into the original data bytes, using the checksum in the last 4 bytes of the decoded data to verify that the rest are correct.
Decodes the given base58 string into the original data bytes, using the checksum in the last 4 bytes of the decoded data to verify that the rest are correct. The checksum is removed from the returned data.
the base58-encoded string to decode (which should include the checksum)
Encodes the given bytes as a base58 string (no checksum is appended).
Encodes the given bytes as a base58 string (no checksum is appended).
the bytes to encode
the base58-encoded string
Encodes the given version and bytes as a base58 string.
Encodes the given version and bytes as a base58 string. A checksum is appended.
Note: This assumes you have already pre-pended the version byte (if applicable)
the bytes to encode, e.g. pubkey hash
the base58-encoded string
Encodes the given version and bytes as a base58 string.
Encodes the given version and bytes as a base58 string. A checksum is appended.
the version to encode
the bytes to encode, e.g. pubkey hash
the base58-encoded string
Base58 is a way to encode Bitcoin addresses (or arbitrary data) as alphanumeric strings.
Note that this is not the same base58 as used by Flickr, which you may find referenced around the Internet.
You may want to consider working with
PrefixedChecksummedBytes
instead, which adds support for testing the prefix and suffix bytes commonly found in addresses.Satoshi explains: why base-58 instead of standard base-64 encoding?
However, note that the encoding/decoding runs in O(n²) time, so it is not useful for large data.
The basic idea of the encoding is to treat the data bytes as a large number represented using base-256 digits, convert the number to be represented using base-58 digits, preserve the exact number of leading zeros (which are otherwise lost during the mathematical operations on the numbers), and finally represent the resulting base-58 digits as alphanumeric ASCII characters.