This project provides Java classes for encrypting and decrypting files using AES (Advanced Encryption Standard) with a 256-bit key. It includes two main components:
Encrypt.java
: Encrypts files with AES encryption.Decrypt.java
: Decrypts files that were encrypted with Encrypt.java
.Encrypt.java
and with a provided padding in Decrypt.java
.releases-latest
Windows Version
javac Encrypt.java
javac Decrypt.java
Use Encrypt
to encrypt a file by specifying the file path and encryption key.
java Encrypt
Use Decrypt
to decrypt a file by specifying the encrypted file path and the decryption key.
java Decrypt
Encrypt.java
padKey(byte[] key)
: Pads the encryption key to a length of 256 bits (32 bytes) with random bytes if the provided key is shorter.encryptFile(String inputFile, byte[] key)
: Encrypts the specified file using AES and saves the result to an output file.Decrypt.java
padKey(byte[] key, byte[] padding)
: Reconstructs the original padded key used for encryption by combining the provided key with the padding.decryptFile(String inputFile, byte[] key)
: Decrypts the specified encrypted file and saves the original content to an output file.Encrypt.java
class saves the IV at the beginning of the encrypted file, which Decrypt.java
reads to ensure secure decryption.This project is open-source and available under the MIT License.