commit 94f9a3624f08d2cb9b81f66a4eae32191adcc7f0 Author: Plexi09 Date: Mon Feb 23 22:33:20 2026 +0100 Intit diff --git a/gpg-encrypted-message b/gpg-encrypted-message new file mode 100644 index 0000000..90b61b7 --- /dev/null +++ b/gpg-encrypted-message @@ -0,0 +1,50 @@ +#!/bin/bash + +echo "GPG Encrypted Message Utility" +echo "1) Write (Encrypt & Sign a message)" +echo "2) Read (Decrypt a message)" +read -p "Select an option (1 or 2): " option + +echo "" + +if [ "$option" == "1" ]; then + # WRITING / ENCRYPTING + read -p "Enter the recipient's email address: " email + read -p "Enter the name for the output file (e.g., secret.asc): " outfile + + echo "----------------------------------------" + echo "Type your secret message below." + echo "When you are finished, press [Enter] to go to a new line, then press [Ctrl+D]." + echo "----------------------------------------" + + # This reads directly from the terminal input and feeds it to GPG + gpg --encrypt --sign --armor --recipient "$email" > "$outfile" + + if [ $? -eq 0 ]; then + echo "" + echo "Success! Message encrypted and saved to '$outfile'." + echo "You can now safely send this file to $email." + else + echo "" + echo "Error: Encryption failed. Are you sure you imported their public key?" + fi + +elif [ "$option" == "2" ]; then + # READING / DECRYPTING + read -p "Enter the path to the encrypted file (e.g., secret.asc): " infile + + if [ -f "$infile" ]; then + echo "" + echo "Decrypting message..." + echo "----------------------------------------" + # GPG automatically knows to use your private key to decrypt + gpg --decrypt "$infile" + echo "" + echo "----------------------------------------" + else + echo "Error: File '$infile' does not exist in this directory." + fi + +else + echo "Invalid option selected. Exiting." +fi \ No newline at end of file