List of usage examples for javax.crypto.spec IvParameterSpec IvParameterSpec
public IvParameterSpec(byte[] iv)
iv
as the IV. From source file:eu.abc4trust.smartcard.HardwareSmartcard.java
public static Cipher getAESKey(String salt, String password, byte[] IV, boolean encrypt) { try {//from w w w . j a v a2 s . c o m // Get the SecretKeySpec SecretKeySpec secretKeySpec = getSecretKeySpec(salt, password); // Instantiate the cipher Cipher cipher = Cipher.getInstance("AES/CBC/pkcs5padding"); if (encrypt) { cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec, new IvParameterSpec(IV)); } else { cipher.init(Cipher.DECRYPT_MODE, secretKeySpec, new IvParameterSpec(IV)); } return cipher; } catch (Exception e) { e.printStackTrace(); return null; } }