What to turn in: Turn in a listing of your code. This should not be long, each of my programs for this lab are far less than 100 lines. Also, demonstrate your program working in lab on or before the due date.
For this lab, you will write two Java programs. One of these will encrypt a file using AES, the other will decrypt the file. Specifically, the encryption program should generate a random key, encrypt using the key, read plaintext from a file, and write the key, IV, and ciphertext to separate files. The decryption program should read the key, IV, and ciphertext, and output the plaintext. The following classes should be useful:
You may accomplish the lab tasks however you want to. A suggested set of steps to encrypt are as follows:
For decrypting, if you used getEncoded to write the key, you will need to use a SecretKeySpec to create the new key based on the written bytes. If you use getIV to write the IV, you can use an instance of IvParameterSpec to help get the IV back into a usable format for the cipher's init method. The rest of decrypting is left as an exercise for you to figure out.
When writing your code, keep in mind that coding style is important. Points will be taken off for unreadable code, including programs with no or minimal comments or programs without proper indentation.