--- a/java/sql-dk/src/info/globalcode/sql/dk/Functions.java Sat Jan 04 19:38:20 2014 +0100
+++ b/java/sql-dk/src/info/globalcode/sql/dk/Functions.java Sat Jan 04 19:38:51 2014 +0100
@@ -141,4 +141,15 @@
Arrays.fill(array, ch);
return new String(array);
}
+ private final static char[] HEX_ALPHABET = "0123456789abcdef".toCharArray();
+
+ public static String toHex(byte[] bytes) {
+ char[] hexChars = new char[bytes.length * 2];
+ for (int j = 0; j < bytes.length; j++) {
+ int v = bytes[j] & 0xFF;
+ hexChars[j * 2] = HEX_ALPHABET[v >>> 4];
+ hexChars[j * 2 + 1] = HEX_ALPHABET[v & 0x0F];
+ }
+ return new String(hexChars);
+ }
}