RSA2048 and AES256 as keys for Java and C#.
Codes used allows encryption and decryption between both languages.
- Change the Constants.java/Constants.cs to the file path in use
- Run Encryptor class to encrypt file (FILE_TO_ENCRYPT)
- Encrypted file: ENCRYPTED_FILE
- Run Decryptor class to decrypt file (ENCRYPTED_FILE)
- Decrypted file: DECRYPTED_FILE
Note: RSA keys can be generated using the RSAKeyGenerator class provided in the Java version.
The expected input/output for file bytes:
[ENCRYPTED_AES_KEY] [IV BYTES] [ENCRYPTED FILE CONTENT]
- Generate an AES key
- Encrypt the file content using the generated AES key (IV is also attached to the file bytes)
- Encrypt the AES key with RSA public key
- Combine encrypted AES key with encrypted file content
- Breakdown file bytes into the three portions (256 AES, 16 IV, Remaining bytes for file content)
- Decrypt AES key with RSA private key
- Decrypt file content using decrypted AES key with IV