From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jean Louis Newsgroups: gmane.emacs.help Subject: Re: epg encrypt non interactive Date: Wed, 6 Jul 2022 11:42:30 +0300 Message-ID: References: <87pmijnfim.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9129"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mutt/+ () (2022-06-11) Cc: Help GNU Emacs To: GH Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jul 06 11:37:03 2022 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 1o91Sw-00029h-6z for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 06 Jul 2022 11:37:02 +0200 Original-Received: from localhost ([::1]:52834 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o91Su-0001JO-2a for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 06 Jul 2022 05:37:00 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53530) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o90er-0005To-GR for help-gnu-emacs@gnu.org; Wed, 06 Jul 2022 04:45:22 -0400 Original-Received: from stw1.rcdrun.com ([217.170.207.13]:60901) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o90em-0004e7-4o for help-gnu-emacs@gnu.org; Wed, 06 Jul 2022 04:45:14 -0400 Original-Received: from localhost ([::ffff:197.239.6.19]) (AUTH: PLAIN admin, TLS: TLS1.3,256bits,ECDHE_RSA_AES_256_GCM_SHA384) by stw1.rcdrun.com with ESMTPSA id 0000000000087C57.0000000062C54B93.00003EF1; Wed, 06 Jul 2022 01:45:06 -0700 Mail-Followup-To: GH , Help GNU Emacs Content-Disposition: inline In-Reply-To: <87pmijnfim.fsf@gnu.org> Received-SPF: pass client-ip=217.170.207.13; envelope-from=bugs@gnu.support; helo=stw1.rcdrun.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_SBL=0.141, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 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:138332 Archived-At: * GH [2022-07-06 05:27]: > > I want encrypt a string using GPG (epg/epa) > > I think that (epg-encrypt-string) is my function to it: > > > (epg-encrypt-string CONTEXT PLAIN RECIPIENTS &optional SIGN > ALWAYS-TRUST) > > Encrypt a string PLAIN. > If RECIPIENTS is nil, it performs symmetric encryption. `epg-encrypt-string' does not have proper documentation. Simple function on my side: (defun rcd-gpg-encrypt (string receiver) "Return the GnuPG STRING encrypted to RECEIVER." (if (rcd-which "gpg") (rcd-command-output-from-input "gpg" string "-e" "-a" "-r" receiver) (rcd-warning-message "RCD ERROR: `gpg' not found in $PATH"))) (defun rcd-command-output-from-input (program input &rest args) "Return output string from PROGRAM with given INPUT string and optional ARGS." (let* ((output (with-temp-buffer (insert input) (apply #'call-process-region nil nil program t '(t nil) nil args) (buffer-string)))) output)) To make it simpler: (defun rcd-gpg-encrypt (string receiver) "Return the GnuPG STRING encrypted to RECEIVER." (rcd-command-output-from-input "/usr/bin/gpg" string "-e" "-a" "-r" receiver)) (rcd-gpg-encrypt "Hello" "bugs@gnu.support") ⇒ "-----BEGIN PGP MESSAGE----- hQEMA6Ilx5GnipwAAQf/X8voSGJSuQwvdk2CTMdvvmY4bg2uRu3ajmsBb9vZ05JO kDc+wi9pdLoC6F3daNeR58yg3OBvPBFsgOWNk8ioS0yux0nhq5s0rSXlBdmQb/ID A2wO2zS7aN3kVePNeqs8Fqej9fNsAD+HoFk8HdP1eTxevPatrC//1CJudcai8Cum +IDcuuuR0vCaeAGlOdLJ5tcqxA1vPkSrWBMNbv40gYc74KRt7pw2VZeyMsPZcvOr C5AKYzDDw/hKGXXr2+LwJjPDJTvCHHuxT+zC/9fMrsHRFlEvT1I+4Y1PgIEpU5kE +CzAGS7KP/XQulwLNMWBSIaKA1JxsznMHuUxmq0wooUCDAMAAAAAAAAAAAEP/0dl PDu0VLUcLKAYmqj/lJbETyXpsm2TIy6PMFyVO2faEhV2s1dFb9w2C4/2xk5xhdUz C1YDDZBf2ZdJjVY9DkQ6oR4TaOV0+IB+RlKum6r0noKxQWZPkRKa+c7k6bl9hJiP SltUldLxkXwlRizLQy/6OYLR9FmbtJZSBR2vwkyGFKqw6zxtMaMAV6mqJbPfMow1 vbhX6Jpv8ShFVf9VVmlGD8pFjX0l6A9TUXO+YLWdQfKJfdwZoo9PN4vunnsAJpxC w3qyKiwnlojXPvQP2RJ5lbjPUwc0N8G3GIFSbJZ+SjXdUJCmDTnNwY/os+QfBfNy 76lc3fbJVOKdYPSssLfRZyNVuFKNRXL2TuKVvVj5rPl5sHvn1woVHcHIEiiCKeQ1 MNuFsXlb3lRBzKs1gPbBVusCZa5FwHVJXm267bNhgIjl7e9EwEf495++CU/oyJtp j2Dmq3mEPKXMmtCgVEJSVSYx7Qq09nbLejSfcfQT33aDkyU2bFoCh7w4aXC4JZyI U+CBFxK2a8YdLWxQhA2YaFJZRmpG90lQhBybFrhnHMvfzDjJf5EUktFEWi310Idm 61A9ymYrsENoPCgZ8cfJzM9L+zGy2yBwRQi8ud4xL5rF5RNDaXoejZwbQB3JiPpA 35vlIVF7BprWGpdMZdRGOGpVDGxY5fg9TIDcpLBL0kABR/I1W5Gj6pLwDL9w0Glm /6tlq+NUoCyZhsrVGa3GJI3IQTRO8pqKIRH5ASJj+SJPTlAP5RiZOQCqxCSZdiUe =KNo5 -----END PGP MESSAGE----- " -- Jean Take action in Free Software Foundation campaigns: https://www.fsf.org/campaigns In support of Richard M. Stallman https://stallmansupport.org/