Class HexUtil

java.lang.Object
org.drasyl.crypto.HexUtil

public final class HexUtil extends Object
Util class that provides hexadecimal functions for drasyl.
  • Method Details

    • fromString

      public static byte[] fromString(String hexString)
      Converts a Hexadecimal String into the corresponding byte[]
      Parameters:
      hexString - e.g. "AB34"
      Returns:
      byte array {AB,34}
      Throws:
      IllegalArgumentException - if string parameter does not conform to lexical value space defined in XML Schema Part 2: Datatypes for xsd:hexBinary.
    • parseHexBinary

      public static byte[] parseHexBinary(String lexicalXSDHexBinary)
      Converts the string argument into an array of bytes.
      Parameters:
      lexicalXSDHexBinary - A string containing lexical representation of xsd:hexBinary.
      Returns:
      An array of bytes represented by the string argument.
      Throws:
      IllegalArgumentException - if string parameter does not conform to lexical value space defined in XML Schema Part 2: Datatypes for xsd:hexBinary.
    • toString

      public static String toString(byte[] byteArray)
      Converts a byte[] into a string representation
      Parameters:
      byteArray - e.g {AB,34}
      Returns:
      string "AB34"
    • bytesToHex

      public static String bytesToHex(byte[] bytes)
      Converts an array of bytes into a string.
      Parameters:
      bytes - an array of bytes
      Returns:
      A string hex representation of the byte array