Intit
This commit is contained in:
commit
94f9a3624f
1 changed files with 50 additions and 0 deletions
50
gpg-encrypted-message
Normal file
50
gpg-encrypted-message
Normal file
|
|
@ -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
|
||||||
Loading…
Add table
Add a link
Reference in a new issue