public static Cipher newCipher(PrivateKey privateKey) throws Exception { Cipher cipher = Cipher.getInstance(CIPHER_ALGORITHM); cipher.init(Cipher.DECRYPT_MODE, privateKey); return cipher; }
public byte[] encrypt(byte[] clearMessage) throws Exception { return _cipher.doFinal(clearMessage); }
public byte[] decrypt(byte[] encryptedMessage) throws Exception { return _cipher.doFinal(encryptedMessage); }
private static Cipher newCipher(SecretKey symmetricKey, IvParameterSpec iv) throws Exception { Cipher cipher = Cipher.getInstance(CIPHER_ALGORITHM); cipher.init(Cipher.DECRYPT_MODE, symmetricKey, iv); return cipher; }