Class Bech32

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Bech32.Bech32Bytes
      Binary data in 5-bits-per-byte format as used in Bech32 encoding/decoding.
      static class  Bech32.Bech32Data
      Bech32 data in 5-bit byte format with Bech32.Encoding and human-readable part (HRP) information.
      static class  Bech32.Encoding
      Enumeration of known Bech32 encoding format types: Bech32 and Bech32m.
    • Constructor Summary

      Constructors 
      Constructor Description
      Bech32()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static Bech32.Bech32Data decode​(java.lang.String str)
      Decode a Bech32 string.
      static byte[] decodeBytes​(java.lang.String bech32, java.lang.String expectedHrp, Bech32.Encoding expectedEncoding)
      Decode a Bech32 string to a byte array.
      static java.lang.String encode​(Bech32.Bech32Data bech32)
      Encode a Bech32 string.
      static java.lang.String encode​(Bech32.Encoding encoding, java.lang.String hrp, Bech32.Bech32Bytes values)
      Encode a Bech32 string.
      static java.lang.String encodeBytes​(Bech32.Encoding encoding, java.lang.String hrp, byte[] bytes)
      Encode a byte array to a Bech32 string
      • Methods inherited from class java.lang.Object

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

      • Bech32

        public Bech32()
    • Method Detail

      • encodeBytes

        public static java.lang.String encodeBytes​(Bech32.Encoding encoding,
                                                   java.lang.String hrp,
                                                   byte[] bytes)
        Encode a byte array to a Bech32 string
        Parameters:
        encoding - Desired encoding Bech32 or Bech32m
        hrp - human-readable part to use for encoding
        bytes - Arbitrary binary data (8-bits per byte)
        Returns:
        A Bech32 string
      • decodeBytes

        public static byte[] decodeBytes​(java.lang.String bech32,
                                         java.lang.String expectedHrp,
                                         Bech32.Encoding expectedEncoding)
        Decode a Bech32 string to a byte array.
        Parameters:
        bech32 - A Bech32 format string
        expectedHrp - Expected value for the human-readable part
        expectedEncoding - Expected encoding
        Returns:
        Decoded value as byte array (8-bits per byte)
        Throws:
        AddressFormatException - if unexpected hrp or encoding
      • encode

        public static java.lang.String encode​(Bech32.Bech32Data bech32)
        Encode a Bech32 string.
        Parameters:
        bech32 - Contains 5-bits/byte data, desired encoding and human-readable part
        Returns:
        A string containing the Bech32-encoded data
      • encode

        public static java.lang.String encode​(Bech32.Encoding encoding,
                                              java.lang.String hrp,
                                              Bech32.Bech32Bytes values)
        Encode a Bech32 string.
        Parameters:
        encoding - The requested encoding
        hrp - The requested human-readable part
        values - Binary data in 5-bit per byte format
        Returns:
        A string containing the Bech32-encoded data