- A Plain Java implementation with Maven and Java for Payload Encryption - using AES for data encryption and RSA for AES key encryption.
- Read data to be sent from a file.
- Generate RSA key pair using BouncyCastle which will store public and private keys in separate files
- Check if you can retrieve information from the respective keys because these will be further used for AES key encryption.
- Encrypt the data to be sent using generated AES key and store it in a file
- Encrypt the AES key using private RSA key and store it in a file to be used later for decryption.
- Read encrypted AES key from a file.
- Decrypt the AES Key with public RSA key
- Decrypt data using the decrypted AES key.
- This will give us the original data.
Note: Any tampering with the RSA/AES key data during data transmission will result in an error on the server side. This ensures that the data sent is secure.
- This code was tested in VSCode with a Maven Java implementation.
- Current size for the RSA key block is 2048.