Function: epg-encrypt-string
epg-encrypt-string is an autoloaded and byte-compiled function defined
in epg.el.gz.
Signature
(epg-encrypt-string CONTEXT PLAIN RECIPIENTS &optional SIGN ALWAYS-TRUST)
Documentation
Encrypt a string PLAIN.
If RECIPIENTS is nil, it performs symmetric encryption.
Source Code
;; Defined in /usr/src/emacs/lisp/epg.el.gz
(defun epg-encrypt-string (context plain recipients
&optional sign always-trust)
"Encrypt a string PLAIN.
If RECIPIENTS is nil, it performs symmetric encryption."
(let ((input-file
(unless (or (not sign)
(eq (epg-context-protocol context) 'CMS))
(make-temp-file "epg-input")))
(coding-system-for-write 'binary))
(unwind-protect
(progn
(setf (epg-context-output-file context)
(make-temp-file "epg-output"))
(if input-file
(write-region plain nil input-file nil 'quiet))
(epg-start-encrypt context
(if input-file
(epg-make-data-from-file input-file)
(epg-make-data-from-string plain))
recipients sign always-trust)
(epg-wait-for-completion context)
(let ((errors (epg-context-result-for context 'error)))
(if (and sign
(not (epg-context-result-for context 'sign)))
(signal 'epg-error
(list "Sign failed" (epg-errors-to-string errors))))
(if errors
(signal 'epg-error
(list "Encrypt failed" (epg-errors-to-string errors)))))
(epg-read-output context))
(epg-delete-output-file context)
(if input-file
(delete-file input-file))
(epg-reset context))))