Skip to content

Instantly share code, notes, and snippets.

@RichardHJensen
Created September 22, 2011 14:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RichardHJensen/1234905 to your computer and use it in GitHub Desktop.
Save RichardHJensen/1234905 to your computer and use it in GitHub Desktop.
Removed byte array initialization from constructor.
public AESEncryptor(byte[] sessionKey, byte[] iv) {
try {
encryptor = Cipher.getInstance("AES/CBC/PKCS5Padding");
encryptor.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(sessionKey, "AES"), new IvParameterSpec(iv));
decryptor = Cipher.getInstance("AES/CBC/PKCS5Padding");
decryptor.init(Cipher.DECRYPT_MODE, new SecretKeySpec(sessionKey, "AES"), encryptor.getParameters());
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (NoSuchPaddingException e) {
e.printStackTrace();
} catch (InvalidKeyException e) {
e.printStackTrace();
} catch (InvalidAlgorithmParameterException e) {
e.printStackTrace();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment