Class Hex

  • All Implemented Interfaces:

    
    public class Hex
    
                        

    Utility class for converting hex data to bytes and back again.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
      Hex()
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      static String toHexString(Array<byte> data)
      static String toHexString(Array<byte> data, int off, int length)
      static Array<byte> encode(Array<byte> data) encode the input data producing a Hex encoded byte array.
      static Array<byte> encode(Array<byte> data, int off, int length) encode the input data producing a Hex encoded byte array.
      static int encode(Array<byte> data, OutputStream out) Hex encode the byte data writing it to the given output stream.
      static int encode(Array<byte> data, int off, int length, OutputStream out) Hex encode the byte data writing it to the given output stream.
      static Array<byte> decode(Array<byte> data) decode the Hex encoded input data.
      static Array<byte> decode(String data) decode the Hex encoded String data - whitespace will be ignored.
      static int decode(String data, OutputStream out) decode the Hex encoded String data writing it to the given output stream, whitespace characters will be ignored.
      static Array<byte> decodeStrict(String str) Decode the hexadecimal-encoded string strictly i.e.
      static Array<byte> decodeStrict(String str, int off, int len) Decode the hexadecimal-encoded string strictly i.e.
      • Methods inherited from class java.lang.Object

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

      • Hex

        Hex()
    • Method Detail

      • encode

         static Array<byte> encode(Array<byte> data)

        encode the input data producing a Hex encoded byte array.

        Returns:

        a byte array containing the Hex encoded data.

      • encode

         static Array<byte> encode(Array<byte> data, int off, int length)

        encode the input data producing a Hex encoded byte array.

        Returns:

        a byte array containing the Hex encoded data.

      • encode

         static int encode(Array<byte> data, OutputStream out)

        Hex encode the byte data writing it to the given output stream.

        Returns:

        the number of bytes produced.

      • encode

         static int encode(Array<byte> data, int off, int length, OutputStream out)

        Hex encode the byte data writing it to the given output stream.

        Returns:

        the number of bytes produced.

      • decode

         static Array<byte> decode(Array<byte> data)

        decode the Hex encoded input data. It is assumed the input data is valid.

        Returns:

        a byte array representing the decoded data.

      • decode

         static Array<byte> decode(String data)

        decode the Hex encoded String data - whitespace will be ignored.

        Returns:

        a byte array representing the decoded data.

      • decode

         static int decode(String data, OutputStream out)

        decode the Hex encoded String data writing it to the given output stream, whitespace characters will be ignored.

        Returns:

        the number of bytes produced.

      • decodeStrict

         static Array<byte> decodeStrict(String str)

        Decode the hexadecimal-encoded string strictly i.e. any non-hexadecimal characters will be considered an error.

        Returns:

        a byte array representing the decoded data.

      • decodeStrict

         static Array<byte> decodeStrict(String str, int off, int len)

        Decode the hexadecimal-encoded string strictly i.e. any non-hexadecimal characters will be considered an error.

        Returns:

        a byte array representing the decoded data.