Java Utililty Methods XML Hex

List of utility methods to do XML Hex

Description

The list of methods to do XML Hex are organized into topic(s).

Method

Stringsha1Hex(String message)
sha1 encryption utility.
byte[] buffer = message.getBytes();
MessageDigest md = MessageDigest.getInstance("SHA1");
md.update(buffer);
byte[] digest = md.digest();
String hash = DatatypeConverter.printHexBinary(digest).toLowerCase();
return hash;
StringstringToHex(String str)
Converts a String to hexadecimal.
byte bytes[] = str.getBytes();
return DatatypeConverter.printHexBinary(bytes);
byte[]toByteArray(String hex)
to Byte Array
if (hex.length() % 2 != 0) {
    hex = "0" + hex;
return DatatypeConverter.parseHexBinary(hex);
byte[]toByteArray(String hexDumpString)
Converts a hex string to byte array
return DatatypeConverter.parseHexBinary(hexDumpString.replaceAll(" ", ""));
byte[]toByteArrayFromHexString(String s)
Returns a byte array from a given hex string.
return DatatypeConverter.parseHexBinary(s);
bytetoByteFromHexString(String hexString)
Returns a byte from a given hex string.
byte[] byteArray = DatatypeConverter.parseHexBinary(hexString);
return byteArray[0];
StringtoHex(byte[] bytes)
Converts a byte array to a lower case hex representation.
if (bytes == null) {
    return "";
} else {
    return DatatypeConverter.printHexBinary(bytes).toLowerCase();
StringtoHex(byte[] bytes)
to Hex
return DatatypeConverter.printHexBinary(bytes);
StringtoHex(byte[] donnees)
to Hex
return javax.xml.bind.DatatypeConverter.printHexBinary(donnees);
StringtoHex(String str)
to Hex
return toHex(str.getBytes());