From: Jean Louis <bugs@gnu.support>
To: GH <project@gnuhacker.org>
Cc: Help GNU Emacs <help-gnu-emacs@gnu.org>
Subject: Re: epg encrypt non interactive
Date: Wed, 6 Jul 2022 11:42:30 +0300 [thread overview]
Message-ID: <YsVK9gS/sCGLI3wt@protected.localdomain> (raw)
In-Reply-To: <87pmijnfim.fsf@gnu.org>
* GH <project@gnuhacker.org> [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/
next prev parent reply other threads:[~2022-07-06 8:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-06 2:25 epg encrypt non interactive GH
2022-07-06 3:50 ` Emanuel Berg
2022-07-06 8:42 ` Jean Louis [this message]
2022-07-07 14:33 ` GH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YsVK9gS/sCGLI3wt@protected.localdomain \
--to=bugs@gnu.support \
--cc=help-gnu-emacs@gnu.org \
--cc=project@gnuhacker.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).