I need to know how to create an AES and using it to encrypt and decrypt a file in java.
Asked
Active
Viewed 5.5k times
14
-
related http://stackoverflow.com/questions/3915644/java-aes-decrypting-problem – andersoj Mar 15 '11 at 04:21
-
2http://stackoverflow.com/questions/992019/java-256bit-aes-encryption shows you how to encrypt a string using AES. To encrypt a File, just read the contents as String, encrypt it and write it back to file. – Nishan Mar 15 '11 at 04:23
1 Answers
8
Try using a CipherOutputStream
and passing in a FileOutputStream
. See http://www.java2s.com/Tutorial/Java/0490__Security/UsingCipherOutputStream.htm for a quick example, just use Cipher.getInstance("AES/CBC/PKCS5Padding")
instead.

WhiteFang34
- 70,765
- 18
- 106
- 111