Advertisement
freddy87

GPG encrypt message/file

Jun 12th, 2016
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. #Script by Freddy87 ([email protected])
  4. #provides option to gpg encrypt messages straight to file or gpg encrypt selected file
  5.  
  6. echo "Do you want to encrypt a (F)ile or (M)essage? " #Option to encrypt file or message
  7. read choice
  8.  
  9. option=$(echo $choice|sed 's/\(.*\)/\L\1/') #converts input to lowercase for matching in if statement
  10.  
  11. if [ $option = "m" ]; then
  12. echo "Enter the message to encrypt: " #creates file with message inside and encrypts it
  13. read message
  14. echo "Enter the name of the recipient: "
  15. read recipient
  16. echo "Enter the name of the output file: "
  17. read outfile
  18. echo "$message" | gpg -o "$outfile.gpg" --encrypt -r "$recipient"
  19. elif [ $option = "f" ]; then
  20. echo "Enter the name of the file to encrypt: " #Encrypts file (standard gpg but more user friendly)
  21. read file_name
  22. echo "Enter the recipient: "
  23. read recipient
  24. echo "Enter the name of the output file: "
  25. read outfile
  26. if [ -n "$outfile" ]; then
  27. gpg -o "$outfile.gpg" --encrypt -r "$recipient" "$file_name"
  28. elif [ -z "$outfile" ]; then
  29. gpg --encrypt -r "$recipient" "$file_name" #if $outfile empty then overwrite
  30. fi
  31. else
  32. echo "That is not a valid option"
  33. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement