Class Base58

  • All Implemented Interfaces:

    
    public class Base58
    
                        

    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 may be referenced online.

    Satoshi explains: Why Base58 instead of standard Base64 encoding?

    • Don't want 0OIl characters that look the same in some fonts and could be used to create visually identical looking account numbers.
    • A string with non-alphanumeric characters is not as easily accepted as an account number.
    • E-mail usually won't line-break if there's no punctuation to break at.
    • Doubleclicking selects the whole number as one word if it's all alphanumeric.

    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 Base256 digits, convert the number to be represented using Base58 digits, preserve the exact number of leading zeros (which are otherwise lost during the mathematical operations on the numbers), and finally represent the resulting Base58 digits as alphanumeric ASCII characters.

    Note that this class originally comes from the Apache licensed bitcoinj library. The original author of this code is the same as the original author of the R3 repository.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
      Base58()
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      static String encode(Array<byte> input) Encodes the given bytes as a Base58 string (no checksum is appended).
      static Array<byte> decode(String input) Decodes the given Base58 string into the original data bytes.
      static BigInteger decodeToBigInteger(String input)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Base58

        Base58()
    • Method Detail

      • encode

         static String encode(Array<byte> input)

        Encodes the given bytes as a Base58 string (no checksum is appended).

        Parameters:
        input - The bytes to encode.
      • decode

         static Array<byte> decode(String input)

        Decodes the given Base58 string into the original data bytes.

        Parameters:
        input - The Base58 encoded string to decode.