Skip to content
Snippets Groups Projects
Commit 7f21b350 authored by felmer's avatar felmer
Browse files

SSDM-3027: add utility methods for converting byte array in a hexstring and vs.

SVN: 36556
parent ef99d153
No related branches found
No related tags found
No related merge requests found
......@@ -23,6 +23,8 @@ import java.util.StringTokenizer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.xml.bind.DatatypeConverter;
import org.apache.commons.lang.StringUtils;
import ch.systemsx.cisd.base.exceptions.CheckedExceptionTunnel;
......@@ -327,5 +329,23 @@ public final class StringUtilities
}
return newStr;
}
/**
* Convert a string of hexadecimal numbers into a byte array.
*/
public static byte[] parseHexString(String hexString)
{
return DatatypeConverter.parseHexBinary(hexString);
}
/**
* Converts a byte array into a string of hexadecimal numbers.
*/
public static String asHexString(byte[] bytesOrNull)
{
return bytesOrNull == null ? null : DatatypeConverter.printHexBinary(bytesOrNull);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment