Class HexDigits

java.lang.Object
io.github.connellite.util.internal.HexDigits

public class HexDigits extends Object
ASCII hex digits: nibble lookup for 0-9, a-f, A-F, and lowercase encoding.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    appendHex(Appendable out, byte value)
    Appends value as 2 lowercase hex digits.
    static void
    appendHex(Appendable out, int value)
    Appends value as 8 lowercase hex digits.
    static void
    appendHex(Appendable out, long value)
    Appends value as 16 lowercase hex digits, most significant nibble first.
    static void
    appendHex(Appendable out, short value)
    Appends value as 4 lowercase hex digits.
    static byte[]
    Decodes an even-length ASCII hex string into bytes.
    static int
    hexValue(int code)
    Returns the hex value of code, or -1 when it is not an ASCII hex digit.
    static String
    toHex(byte[] bytes)
    Encodes bytes as lowercase hex, two characters per byte.

    Methods inherited from class java.lang.Object

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

    • HexDigits

      public HexDigits()
  • Method Details

    • hexValue

      public static int hexValue(int code)
      Returns the hex value of code, or -1 when it is not an ASCII hex digit.
    • appendHex

      public static void appendHex(Appendable out, byte value)
      Appends value as 2 lowercase hex digits.
    • appendHex

      public static void appendHex(Appendable out, short value)
      Appends value as 4 lowercase hex digits.
    • appendHex

      public static void appendHex(Appendable out, int value)
      Appends value as 8 lowercase hex digits.
    • appendHex

      public static void appendHex(Appendable out, long value)
      Appends value as 16 lowercase hex digits, most significant nibble first.
    • toHex

      public static String toHex(byte[] bytes)
      Encodes bytes as lowercase hex, two characters per byte.
    • fromHex

      public static byte[] fromHex(String hex)
      Decodes an even-length ASCII hex string into bytes.
      Returns:
      decoded bytes, or null if hex contains a non-hex character