We incorporate HMAC Function from cryptography.hazmat.primitives to compute and verify the HMAC.
After encrypting the file, we will compute the HMAC of the encrypted content using the same key, and append it to the output file.
Before decrypting, we will extract the HMAC from the encrypted file and verify it against the encrypted content to ensure data integrity.
For Debugging Purposes the HMAC keys are getting printed on the terminal.
Major Changes :
HMAC Generation (generate_hmac): An HMAC is created for the encrypted data using the encryption key.
HMAC Verification (verify_hmac): During decryption, the HMAC of the encrypted content is compared with the stored HMAC to verify the file's integrity.
File Structure:
When using password-based encryption, the salt is stored at the beginning of the file.
The encrypted content is followed by the HMAC, ensuring integrity.
With this feature, the script not only encrypts and decrypts files but also ensures that the data hasn’t been modified or tampered with during transmission or storage.
This PR Resolves the Issue#6
Major Changes :
With this feature, the script not only encrypts and decrypts files but also ensures that the data hasn’t been modified or tampered with during transmission or storage.