Actualiser gpg-encrypted-message.sh
This commit is contained in:
parent
94f9a3624f
commit
a957c18ba4
1 changed files with 25 additions and 1 deletions
|
|
@ -1,50 +0,0 @@
|
|||
#!/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