Package libcore.util

Class HexEncoding


  • public class HexEncoding
    extends Object
    Hexadecimal encoding where each byte is represented by two hexadecimal digits.
    • Method Detail

      • encode

        public static char[] encode​(byte[] data)
        Encodes the provided data as a sequence of hexadecimal characters.
      • encode

        public static char[] encode​(byte[] data,
                                    int offset,
                                    int len)
        Encodes the provided data as a sequence of hexadecimal characters.
      • decode

        public static byte[] decode​(char[] encoded,
                                    boolean allowSingleChar)
                             throws IllegalArgumentException
        Decodes the provided hexadecimal string into a byte array. If allowSingleChar is true odd-length inputs are allowed and the first character is interpreted as the lower bits of the first result byte. Throws an IllegalArgumentException if the input is malformed.
        Throws:
        IllegalArgumentException