help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Transparent encrypt and decrypt token file with gpg2 in Emacs.


From: Hongyi Zhao
Subject: Re: Transparent encrypt and decrypt token file with gpg2 in Emacs.
Date: Thu, 10 Jun 2021 13:08:22 +0800

On Thu, Jun 10, 2021 at 10:19 AM Hongyi Zhao <hongyi.zhao@gmail.com> wrote:
>
> On Thu, Jun 10, 2021 at 12:06 AM Jean Louis <bugs@gnu.support> wrote:
> >
> > * Hongyi Zhao <hongyi.zhao@gmail.com> [2021-06-09 18:28]:
> > > Loading /home/werner/DvdMgr/screen2latex.el.git/auth.el.gpg...
> > > Decrypting /home/werner/DvdMgr/screen2latex.el.git/auth.el.gpg...done
> > > epa-file-insert-file-contents: Opening input file: Can't decrypt, No
> > > data (no armored data); No data (expected a packet but did not find
> > > one); Exit
> > > Mark set [4 times]
> >
> > Send the file for review.
> >
> > If it is encrypted, there should be nothing much to worry... ^‿^
>
> If I first store the plain/unencrypted token info into a file, say,
> named as auth.el, and then encrypt it outside of Emacs with gpg(2) as
> below, the problem will disappear:
>
> $ gpg2 -o auth.el.gpg -e -r hongyi.zhao@gmail.com auth.el
> # Then remove the plain version of the token info.
> $ rm auth.el
>
> But I still can't figure out how to let Emacs do the above job for me
> automatically when the token file is read by Emacs in an unencrypted
> format for the first time.

I figured out the Emacs way of this job based on the wonderful Emacs
manual as described at
<https://www.gnu.org/software/emacs/manual/html_node/epa/Encrypting_002fdecrypting-gpg-files.html>:

<quote>
3.6 Encrypting/decrypting gpg files

By default, every file whose name ends with .gpg will be treated as
encrypted. That is, when you open such a file, the decrypted text is
inserted in the buffer rather than encrypted one. Similarly, when you
save the buffer to a foo.gpg file, encrypted data is written.

The file name pattern for encrypted files can be controlled by
epa-file-name-regexp.
</quote>

Once again, the RTFM philosophy shows its power and enduring value.

Regards
-- 
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
NO. 552 North Gangtie Road, Xingtai, China



reply via email to

[Prev in Thread] Current Thread [Next in Thread]