Function: epg-sign-string
epg-sign-string is a byte-compiled function defined in epg.el.gz.
Signature
(epg-sign-string CONTEXT PLAIN &optional MODE)
Documentation
Sign a string PLAIN and return the output as string.
If optional 3rd argument MODE is t or detached, it makes a detached signature.
If it is nil or normal, it makes a normal signature.
Otherwise, it makes a cleartext signature.
Source Code
;; Defined in /usr/src/emacs/lisp/epg.el.gz
(defun epg-sign-string (context plain &optional mode)
"Sign a string PLAIN and return the output as string.
If optional 3rd argument MODE is t or `detached', it makes a detached signature.
If it is nil or `normal', it makes a normal signature.
Otherwise, it makes a cleartext signature."
(let ((input-file
(unless (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-sign context
(if input-file
(epg-make-data-from-file input-file)
(epg-make-data-from-string plain))
mode)
(epg-wait-for-completion context)
(unless (epg-context-result-for context 'sign)
(if (epg-context-result-for context 'error)
(let ((errors (epg-context-result-for context 'error)))
(signal 'epg-error
(list "Sign failed" (epg-errors-to-string errors))))
(signal 'epg-error '("Signing failed (unknown reason)"))))
(epg-read-output context))
(epg-delete-output-file context)
(if input-file
(delete-file input-file))
(epg-reset context))))