public static byte[] encrypt(byte[] plainText, byte[] key, byte[] initialVector) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException, IllegalBlockSizeException, BadPaddingException { System.out.println("Indside encrypt"); Cipher cipher = Cipher.getInstance(cipherTransformation); System.out .println("cipher object created now key specification object creation"); SecretKeySpec secretKeySpec = new SecretKeySpec(key, aesEncryptionAlgorithm); System.out.println("key specification object created"); IvParameterSpec ivParameterSpec = new IvParameterSpec(initialVector); cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec, ivParameterSpec); System.out.println("cipher init successfull" + plainText.length); int bytesLenght = plainText.length; plainText = cipher.doFinal(plainText); System.out.println("return encrypted bytes"); return plainText; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)