From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Hongyi Zhao Newsgroups: gmane.emacs.help Subject: Re: Transparent encrypt and decrypt token file with gpg2 in Emacs. Date: Thu, 10 Jun 2021 13:08:22 +0800 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22561"; mail-complaints-to="usenet@ciao.gmane.io" To: Hongyi Zhao , help-gnu-emacs Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jun 10 07:09:18 2021 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lrCwQ-0005gI-5A for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 10 Jun 2021 07:09:18 +0200 Original-Received: from localhost ([::1]:60812 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lrCwP-0007ge-6t for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 10 Jun 2021 01:09:17 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38578) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lrCvm-0007F1-2b for help-gnu-emacs@gnu.org; Thu, 10 Jun 2021 01:08:38 -0400 Original-Received: from mail-lf1-x136.google.com ([2a00:1450:4864:20::136]:42725) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lrCvk-0002Sn-Ef for help-gnu-emacs@gnu.org; Thu, 10 Jun 2021 01:08:37 -0400 Original-Received: by mail-lf1-x136.google.com with SMTP id j2so1040478lfg.9 for ; Wed, 09 Jun 2021 22:08:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :content-transfer-encoding; bh=szrO+69TTEnvIv1EWvWOSMjNLPjpKlQKiU2gosmsKGs=; b=KuqWGYjsMHm+yTjk3BLzTWbmJK5cpvrTfp+TX60ZpPXGklP7AeBIymNdDISl0F3rB5 RyIITZHX8g5XIqqu5mPwUQfFS/2POWKvyWF8G6nQpumhpJa75kZbwBSe4vZlJS7hYxKq A+loTMafP+b2oJcFbCRLNSrCPhQfPTPap2n4N+whq3go/PpQrF+I+0gAVGhZRl/q2MX9 CqjP3TxinKpegMKFNz5qf1zud4L7qdLCPOmWwaJVZztAXWJUkYGLnk7/LnCAYHy9zM7I C9tR3cZVhnIEJOAuVNti4liopSGuvvBRyQY3xwVMfbDgy5Az0EKDKF52MK5DgXci5TCp a5SA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:content-transfer-encoding; bh=szrO+69TTEnvIv1EWvWOSMjNLPjpKlQKiU2gosmsKGs=; b=NIPz39rvZrRAws/oIeKVItKtgXD26Oo6nS9X8vmRb7osLLHCwXYrbyY6doD99rGtKt ggqjnODAwRvVSgx63r3/9nxipMHw5Sd2ybceqLp4EVC9++Ug7mEya+V6IQdGDf1ecEut e8NI/A4j7scwsXscT9cr2O1V2iidKsvMeh/PDflgz/hH4LtGah5cxGfRtOPZ7HY3FZu7 yRSriy7Tuc58i567bqeqqpQIy1GzBFYuX86w6PCQeuplAZLHgO1ADuXAtKrHpHsqKKNd hJTr9H4OcVeTn6TmqpC19BCOKL0oBm3dX1OOP0bvfvMwjU2qRmZBFkSGQvNLT4n79/4+ kTtw== X-Gm-Message-State: AOAM530o+C4hO0mNDDtoDjJh9DCZyCegdWMNJGfu+IrxTGd5gU6sdqdC /cbYC4yXTaRykGaI5DZ7JnihbGMXjDAFRnfarck= X-Google-Smtp-Source: ABdhPJyYBHWhqzVXbDpsiSLEe108BBakEAkKl1xEoBePCagqxbbLJTrLC2n4AFHmTyx251Y0syJ4DF2YDds0g6Z9UuM= X-Received: by 2002:a19:5e18:: with SMTP id s24mr757162lfb.545.1623301714394; Wed, 09 Jun 2021 22:08:34 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=2a00:1450:4864:20::136; envelope-from=hongyi.zhao@gmail.com; helo=mail-lf1-x136.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:130693 Archived-At: On Thu, Jun 10, 2021 at 10:19 AM Hongyi Zhao wrote: > > On Thu, Jun 10, 2021 at 12:06 AM Jean Louis wrote: > > > > * Hongyi Zhao [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... ^=E2=80=BF= ^ > > 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 : 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. Once again, the RTFM philosophy shows its power and enduring value. Regards --=20 Assoc. Prof. Hongyi Zhao Theory and Simulation of Materials Hebei Vocational University of Technology and Engineering NO. 552 North Gangtie Road, Xingtai, China