Introduction:
This bash script utilizes GPG to encrypt files, ensuring that sensitive data remains secure. You can specify the file to encrypt and the recipient's key for encryption.
Instructions:
To encrypt a file, use these commands:
Example Output:
This bash script utilizes GPG to encrypt files, ensuring that sensitive data remains secure. You can specify the file to encrypt and the recipient's key for encryption.
Bash:
#!/bin/bash
if [ $# -ne 2 ]; then
echo "Usage: $0 filename recipient_email"
exit 1
fi
file=$1
recipient=$2
gpg --output ${file}.gpg --encrypt --recipient $recipient $file
echo "File $file has been encrypted for $recipient."
Instructions:
To encrypt a file, use these commands:
Code:
chmod +x file_encrypt.sh
./file_encrypt.sh sample.txt user@example.com
Example Output:
Code:
File sample.txt has been encrypted for user@example.com.