Package org.drasyl.crypto
Class HexUtil
java.lang.Object
org.drasyl.crypto.HexUtil
Util class that provides hexadecimal functions for drasyl.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringbytesToHex(byte[] bytes) Converts an array of bytes into a string.static byte[]fromString(String hexString) Converts a Hexadecimal String into the corresponding byte[]static byte[]parseHexBinary(String lexicalXSDHexBinary) Converts the string argument into an array of bytes.static StringtoString(byte[] byteArray) Converts a byte[] into a string representation
-
Method Details
-
fromString
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
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
Converts a byte[] into a string representation- Parameters:
byteArray- e.g {AB,34}- Returns:
- string "AB34"
-
bytesToHex
Converts an array of bytes into a string.- Parameters:
bytes- an array of bytes- Returns:
- A string hex representation of the byte array
-