Class Base58


  • public class Base58
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static char[] ALPHABET  
    • Constructor Summary

      Constructors 
      Constructor Description
      Base58()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static byte[] decode​(java.lang.String input)
      Decodes the given base58 string into the original data bytes.
      static byte[] decodeChecked​(java.lang.String input)
      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.
      static java.math.BigInteger decodeToBigInteger​(java.lang.String input)  
      static java.lang.String encode​(byte[] input)
      Encodes the given bytes as a base58 string (no checksum is appended).
      static java.lang.String encodeChecked​(int version, byte[] payload)
      Encodes the given version and bytes as a base58 string.
      • Methods inherited from class java.lang.Object

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

      • ALPHABET

        public static final char[] ALPHABET
    • Constructor Detail

      • Base58

        public Base58()
    • Method Detail

      • encode

        public static java.lang.String encode​(byte[] input)
        Encodes the given bytes as a base58 string (no checksum is appended).
        Parameters:
        input - the bytes to encode
        Returns:
        the base58-encoded string
      • encodeChecked

        public static java.lang.String encodeChecked​(int version,
                                                     byte[] payload)
        Encodes the given version and bytes as a base58 string. A checksum is appended.
        Parameters:
        version - the version to encode
        payload - the bytes to encode, e.g. pubkey hash
        Returns:
        the base58-encoded string
      • decode

        public static byte[] decode​(java.lang.String input)
                             throws AddressFormatException
        Decodes the given base58 string into the original data bytes.
        Parameters:
        input - the base58-encoded string to decode
        Returns:
        the decoded data bytes
        Throws:
        AddressFormatException - if the given string is not a valid base58 string
      • decodeChecked

        public static byte[] decodeChecked​(java.lang.String input)
                                    throws AddressFormatException
        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.
        Parameters:
        input - the base58-encoded string to decode (which should include the checksum)
        Throws:
        AddressFormatException - if the input is not base 58 or the checksum does not validate.