From a957c18ba4125e342bd62be20cead42e79d6e7fa Mon Sep 17 00:00:00 2001 From: Plexi09 Date: Mon, 23 Feb 2026 22:35:30 +0100 Subject: [PATCH] Actualiser gpg-encrypted-message.sh --- ...rypted-message => gpg-encrypted-message.sh | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) rename gpg-encrypted-message => gpg-encrypted-message.sh (61%) diff --git a/gpg-encrypted-message b/gpg-encrypted-message.sh similarity index 61% rename from gpg-encrypted-message rename to gpg-encrypted-message.sh index 90b61b7..b999e0e 100644 --- a/gpg-encrypted-message +++ b/gpg-encrypted-message.sh @@ -3,7 +3,8 @@ 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 "3) Import someone's public key" +read -p "Select an option (1, 2, or 3): " option echo "" @@ -45,6 +46,29 @@ elif [ "$option" == "2" ]; then echo "Error: File '$infile' does not exist in this directory." 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 echo "Invalid option selected. Exiting." fi \ No newline at end of file