Class HexConverter

java.lang.Object
io.debezium.util.HexConverter

public class HexConverter extends Object
COPIED FROM https://github.com/undertow-io/undertow/blob/master/core/src/main/java/io/undertow/util/HexConverter.java A utility class for mapping between byte arrays and their hex representation and back again.
Author:
Darran Lofthouse
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final byte[]
     
    private static final char[]
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static byte[]
    convertFromHex(char[] toConvert)
    Take the incoming character of hex encoded data and convert to the raw byte values.
    static byte[]
    Take the incoming String of hex encoded data and convert to the raw byte values.
    static byte[]
    convertToHexBytes(byte[] toBeConverted)
    Take the supplied byte array and convert it to to a byte array of the encoded hex values.
    static String
    convertToHexString(byte[] toBeConverted)
    Take the supplied byte array and convert it to a hex encoded String.
    private static byte
    toByte(char[] toConvert, int pos)
     

    Methods inherited from class java.lang.Object

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

    • HEX_CHARS

      private static final char[] HEX_CHARS
    • HEX_BYTES

      private static final byte[] HEX_BYTES
  • Constructor Details

    • HexConverter

      public HexConverter()
  • Method Details

    • convertToHexString

      public static String convertToHexString(byte[] toBeConverted)
      Take the supplied byte array and convert it to a hex encoded String.
      Parameters:
      toBeConverted - - the bytes to be converted.
      Returns:
      the hex encoded String.
    • convertToHexBytes

      public static byte[] convertToHexBytes(byte[] toBeConverted)
      Take the supplied byte array and convert it to to a byte array of the encoded hex values.

      Each byte on the incoming array will be converted to two bytes on the return array.

      Parameters:
      toBeConverted - - the bytes to be encoded.
      Returns:
      the encoded byte array.
    • convertFromHex

      public static byte[] convertFromHex(char[] toConvert)
      Take the incoming character of hex encoded data and convert to the raw byte values.

      The characters in the incoming array are processed in pairs with two chars of a pair being converted to a single byte.

      Parameters:
      toConvert - - the hex encoded String to convert.
      Returns:
      the raw byte array.
    • toByte

      private static byte toByte(char[] toConvert, int pos)
    • convertFromHex

      public static byte[] convertFromHex(String toConvert)
      Take the incoming String of hex encoded data and convert to the raw byte values.

      The characters in the incoming String are processed in pairs with two chars of a pair being converted to a single byte.

      Parameters:
      toConvert - - the hex encoded String to convert.
      Returns:
      the raw byte array.