Actualiser gpg-encrypted-message.sh

This commit is contained in:
Plexi09 2026-02-23 22:35:30 +01:00
parent 94f9a3624f
commit a957c18ba4

View file

@ -3,7 +3,8 @@
echo "GPG Encrypted Message Utility" echo "GPG Encrypted Message Utility"
echo "1) Write (Encrypt & Sign a message)" echo "1) Write (Encrypt & Sign a message)"
echo "2) Read (Decrypt a message)" echo "2) Read (Decrypt a message)"
read -p "Select an option (1 or 2): " option echo "3) Import someone's public key"
read -p "Select an option (1, 2, or 3): " option
echo "" echo ""
@ -45,6 +46,29 @@ elif [ "$option" == "2" ]; then
echo "Error: File '$infile' does not exist in this directory." echo "Error: File '$infile' does not exist in this directory."
fi fi
elif [ "$option" == "3" ]; then
# IMPORTING PUBLIC KEY
read -p "Enter the path to the public key file you want to import (e.g., friend_key.asc): " keyfile
if [ -f "$keyfile" ]; then
echo ""
echo "Importing public key from '$keyfile'..."
echo "----------------------------------------"
gpg --import "$keyfile"
if [ $? -eq 0 ]; then
echo "----------------------------------------"
echo "Success! The public key has been added to your keychain."
echo "You can now use Option 1 to send encrypted messages to this person."
else
echo "----------------------------------------"
echo "Error: Failed to import the key. Make sure it is a valid GPG public key file."
fi
else
echo "Error: File '$keyfile' does not exist in this directory."
fi
else else
echo "Invalid option selected. Exiting." echo "Invalid option selected. Exiting."
fi fi