public static long decryptCTR(final byte[] concatenatedHashValue,final String base64EncryptedTurnOverValue,final SecretKey symmetricKey) throws NoSuchAlgorithmException, NoSuchProviderException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException, IllegalBlockSizeException, BadPaddingException {
  final ByteBuffer byteBufferIV=ByteBuffer.allocate(16);
  byteBufferIV.put(concatenatedHashValue);
  final byte[] IV=byteBufferIV.array();
  final byte[] encryptedTurnOverValue=CashBoxUtils.base64Decode(base64EncryptedTurnOverValue,false);
  final IvParameterSpec ivSpec=new IvParameterSpec(IV);
  final Cipher cipher=Cipher.getInstance("AES/CTR/NoPadding","BC");
  cipher.init(Cipher.DECRYPT_MODE,symmetricKey,ivSpec);
  final byte[] testPlainTurnOverValueComplete=cipher.doFinal(encryptedTurnOverValue);
  return getLong(testPlainTurnOverValueComplete);
}

public static long decryptCTR ( final byte [ ] concatenatedHashValue , final String base64EncryptedTurnOverValue , final SecretKey symmetricKey ) throws NoSuchAlgorithmException , NoSuchProviderException , NoSuchPaddingException , InvalidKeyException , InvalidAlgorithmParameterException , IllegalBlockSizeException , BadPaddingException { final ByteBuffer byteBufferIV = ByteBuffer . allocate ( 16 ) ; byteBufferIV . put ( concatenatedHashValue ) ; final byte [ ] IV = byteBufferIV . array ( ) ; final byte [ ] encryptedTurnOverValue = CashBoxUtils . base64Decode ( base64EncryptedTurnOverValue , false ) ; final IvParameterSpec ivSpec = new IvParameterSpec ( IV ) ; final Cipher cipher = Cipher . getInstance ( "AES/CTR/NoPadding" , "BC" ) ; cipher . init ( Cipher . DECRYPT_MODE , symmetricKey , ivSpec ) ; final byte [ ] testPlainTurnOverValueComplete = cipher . doFinal ( encryptedTurnOverValue ) ; return getLong ( testPlainTurnOverValueComplete ) ; }
method for aes decryption in ctr mode
