@Test(expected = DecryptException.class) public void AsBytesShouldFailWhenGivenBadInput() throws DecryptException { String testHex; byte notUsed = -1; testHex = "bbb"; CryptoUtil.asBytes(testHex, notUsed); }
protected static byte[] asBytes(String hexString, byte padByte) throws DecryptException { byte[] number = new byte[hexString.length() / 2]; try { for (int i = 0; i < hexString.length(); i += 2) { int j = Integer.parseInt(hexString.substring(i, i + 2), 16); number[i / 2] = (byte) (j & 0x000000ff); } } catch (StringIndexOutOfBoundsException ex) { ex.printStackTrace(); throw new DecryptException("Invalid hex string"); } return number; }
CryptoUtil { protected static byte[] asBytes(String hexString, byte padByte) throws DecryptException { byte[] number = new byte[hexString.length() / 2]; try { for (int i = 0; i < hexString.length(); i += 2) { int j = Integer.parseInt(hexString.substring(i, i + 2), 16); number[i / 2] = (byte) (j & 0x000000ff); } } catch (StringIndexOutOfBoundsException ex) { ex.printStackTrace(); throw new DecryptException("Invalid hex string"); } return number; } }
CryptoUtil { protected static byte[] asBytes(String hexString, byte padByte) throws DecryptException { byte[] number = new byte[hexString.length() / 2]; try { for (int i = 0; i < hexString.length(); i += 2) { int j = Integer.parseInt(hexString.substring(i, i + 2), 16); number[i / 2] = (byte) (j & 0x000000ff); } } catch (StringIndexOutOfBoundsException ex) { ex.printStackTrace(); throw new DecryptException("Invalid hex string"); } return number; } private  CryptoUtil(); }
CryptoUtil { protected static byte[] asBytes(String hexString, byte padByte) throws DecryptException { byte[] number = new byte[hexString.length() / 2]; try { for (int i = 0; i < hexString.length(); i += 2) { int j = Integer.parseInt(hexString.substring(i, i + 2), 16); number[i / 2] = (byte) (j & 0x000000ff); } } catch (StringIndexOutOfBoundsException ex) { ex.printStackTrace(); throw new DecryptException("Invalid hex string"); } return number; } private  CryptoUtil(); static String decrypt(String encrypted); static String encrypt(String decrypted); static int getMaxKeySize(); }
CryptoUtil { protected static byte[] asBytes(String hexString, byte padByte) throws DecryptException { byte[] number = new byte[hexString.length() / 2]; try { for (int i = 0; i < hexString.length(); i += 2) { int j = Integer.parseInt(hexString.substring(i, i + 2), 16); number[i / 2] = (byte) (j & 0x000000ff); } } catch (StringIndexOutOfBoundsException ex) { ex.printStackTrace(); throw new DecryptException("Invalid hex string"); } return number; } private  CryptoUtil(); static String decrypt(String encrypted); static String encrypt(String decrypted); static int getMaxKeySize(); static final String ENCODING; }