0

i've been writing into a text file, using gedit. today i decided it will be a good idea to password protect it. i've searched quite a bit on google, and finally came up with this solution, which actually is quite nice, i'm referring to @parto's answer, which includes enabling the external tools and adding some scripts. i did everything as written there, including using the proposed CTRL+SHIFT+E/D shortcuts, now, when i activate the encryption, it works as expected and i can save the file regularly, the thing is, that when i try to open it, after i type in the password, it creates a new file instead of replacing the current one. (I did choose the replace current file at the output option..) another curious thing is - for example my starting file name was - EmptyDocument, when i opened it, a new file called EmptyDocu was created, i examined it a bit further and when i encrypt that file and try to open it, a new file called Empty was created, and after that a file called Deskt, which got me thinking there must be something wrong with the script.. the answer is for two years ago, so maybe something has changed in the way this should be written.. unfortunately i was unsuccessful at finding an answer. so i decided to reach out and maybe someone here can help.. the script i copied is:

#!/bin/bash
stdin=$(cat)

if [ "${stdin:0:27}" == "-----BEGIN PGP MESSAGE-----"  ]; then 
    echo "$stdin" | gpg -d --no-tty - 2> /dev/null
else
    echo "$stdin"
fi

i also tried adding -o - after 2> /dev/null (i read at the gpg manual that - is for stdout..)

well, here's hoping for the best.

  • I think you're making this more complicated than it needs to be. You don't need a script to encrypt files with gnupg. – Paul Benson Dec 01 '19 at 20:57
  • @PaulBenson the point was to use gedit.. – ariel t Dec 02 '19 at 16:21
  • You use gedit to make your text file, then you encrypt it - gpg -c mytextfile. Job done. – Paul Benson Dec 02 '19 at 16:48
  • well, i want to double-click the file, enter the passphrase, get it to open. then i want to enter some more text, encrypt it, and save it. all in a convenient way without using the terminal... should be simple enough.. – ariel t Dec 03 '19 at 07:05
  • well, in the meantime i found a workaround to this.. it seems that when i clicked on the file, it executed the decryption script, so i changed that behavior to open the file with the gedit without the aforementioned script. which opened the file, i then activate the decryption, and it stays within the same file. as i wanted.. – ariel t Dec 07 '19 at 20:06
  • The workaround is to use a GUI like Seahorse if you use asymmetric keys as I do. No shell commands needed, although I still prefer using them. But it won't work for the simpler symmetric encryption (gpg -c mytextfile) as mentioned previously. – Paul Benson Dec 10 '19 at 11:37

0 Answers0