@Test public void AsHex() { byte[] testBytes; String actual; String expected; testBytes = new byte[]{0, 0, 0}; expected = "000000"; actual = CryptoUtil.asHex(testBytes); assertEquals("3 byte min value", expected, actual); testBytes = new byte[]{-1, -1, -1}; expected = "ffffff"; actual = CryptoUtil.asHex(testBytes); assertEquals("3 byte max value", expected, actual); testBytes = new byte[]{16, 16, 16}; expected = "101010"; actual = CryptoUtil.asHex(testBytes); assertEquals("3 byte 16s place", expected, actual); testBytes = new byte[]{1, 1, 1}; expected = "010101"; actual = CryptoUtil.asHex(testBytes); assertEquals("3 byte 1s place", expected, actual); }
protected static String asHex(byte bytes[]) { StringBuilder sb = new StringBuilder(bytes.length * 2); for (int i = 0; i < bytes.length; i++) { if ((bytes[i] & 0xff) < 0x10) { sb.append("0"); } sb.append(Long.toString(bytes[i] & 0xff, 16)); } return sb.toString(); }
CryptoUtil { protected static String asHex(byte bytes[]) { StringBuilder sb = new StringBuilder(bytes.length * 2); for (int i = 0; i < bytes.length; i++) { if ((bytes[i] & 0xff) < 0x10) { sb.append("0"); } sb.append(Long.toString(bytes[i] & 0xff, 16)); } return sb.toString(); } }
CryptoUtil { protected static String asHex(byte bytes[]) { StringBuilder sb = new StringBuilder(bytes.length * 2); for (int i = 0; i < bytes.length; i++) { if ((bytes[i] & 0xff) < 0x10) { sb.append("0"); } sb.append(Long.toString(bytes[i] & 0xff, 16)); } return sb.toString(); } private  CryptoUtil(); }
CryptoUtil { protected static String asHex(byte bytes[]) { StringBuilder sb = new StringBuilder(bytes.length * 2); for (int i = 0; i < bytes.length; i++) { if ((bytes[i] & 0xff) < 0x10) { sb.append("0"); } sb.append(Long.toString(bytes[i] & 0xff, 16)); } return sb.toString(); } private  CryptoUtil(); static String decrypt(String encrypted); static String encrypt(String decrypted); static int getMaxKeySize(); }
CryptoUtil { protected static String asHex(byte bytes[]) { StringBuilder sb = new StringBuilder(bytes.length * 2); for (int i = 0; i < bytes.length; i++) { if ((bytes[i] & 0xff) < 0x10) { sb.append("0"); } sb.append(Long.toString(bytes[i] & 0xff, 16)); } return sb.toString(); } private  CryptoUtil(); static String decrypt(String encrypted); static String encrypt(String decrypted); static int getMaxKeySize(); static final String ENCODING; }