This code encrypts files in the Downloads and Documents folders on the user's local machine and sends the decryption key via email. It uses AES encryption with a randomly generated key.
- Go version 1.14 or higher
- crypto/aes
- crypto/cipher
- crypto/rand
- encoding/base64
- encoding/json
- io
- io/ioutil
- net/http
- os
- os/user
- path/filepath
- strings
- The code gets the path for the Downloads and Documents folders on the user's local machine.
- It generates a random AES key of 32 bytes.
- The key is then sent via email to the address "paulkiragu621@gmail.com" with the subject "Decryption Key for [USERNAME]" using the SendGrid API.
- The code then encrypts every file in the Downloads and Documents Folders using the AES encryption and saves the encrypted files with a ".aes" file extension.
- Replace the X-RapidAPI-Key and X-RapidAPI-Host in the headers variable with your own API key and host obtained from SendGrid.
- Replace the 'to' email address in the payload variable with the desired email address to receive the decryption key.
- Replace the 'from' email address in the payload variable with the desired email address to send the decryption key.
- Run the code by executing go run main.go in the terminal.
- The encrypted files can be decrypted using the key sent via email and the AES decryption process.
This code is for demonstration purposes only and should not be used in a production environment without modification and proper security measures.