} catch (UnsupportedEncodingException e) {
throw new IllegalStateException(e);
}
- String sentNonce = String.format(
- "%d-%20X", new Long(timestamp), rawHmac); //$NON-NLS-1$
- return sentNonce;
+ return Long.toString(timestamp) + "-" + toHex(rawHmac); //$NON-NLS-1$
}
@Override
return NonceStatus.SLOP;
}
}
+
+ private static final String HEX = "0123456789ABCDEF"; //$NON-NLS-1$
+
+ private static String toHex(byte[] bytes) {
+ StringBuilder builder = new StringBuilder(2 * bytes.length);
+ for (byte b : bytes) {
+ builder.append(HEX.charAt((b & 0xF0) >> 4));
+ builder.append(HEX.charAt(b & 0xF));
+ }
+ return builder.toString();
+ }
}