(context (epg-make-context)))
(message "Decrypting %s..." (file-name-nondirectory file))
(epg-decrypt-file context file plain)
- (message "Decrypting %s...done" (file-name-nondirectory file))))
+ (message "Decrypting %s...done" (file-name-nondirectory file))
+ (if (epg-context-result-for context 'verify)
+ (message "%s"
+ (epg-verify-result-to-string
+ (epg-context-result-for context 'verify))))))
;;;###autoload
(defun epa-verify-file (file)
(epg-sign-keys context keys local)
(message "Signing keys...done")))
+;;;###autoload
+(defun epa-decrypt-region (start end)
+ "Decrypt OpenPGP armors in the current region between START and END."
+ (interactive "r")
+ (save-excursion
+ (save-restriction
+ (narrow-to-region start end)
+ (goto-char start)
+ (let (armor-start armor-end charset context plain coding-system)
+ (while (re-search-forward "-----BEGIN PGP MESSAGE-----$" nil t)
+ (setq armor-start (match-beginning 0)
+ armor-end (re-search-forward "^-----END PGP MESSAGE-----$"
+ nil t))
+ (unless armor-end
+ (error "No armor tail"))
+ (goto-char armor-start)
+ (if (re-search-forward "^Charset: \\(.*\\)" nil t)
+ (setq charset (match-string 1)))
+ (setq context (epg-make-context)
+ plain (epg-decrypt-string
+ context
+ (buffer-substring armor-start armor-end)))
+ (delete-region armor-start armor-end)
+ (goto-char armor-start)
+ (if coding-system-for-read
+ (setq coding-system coding-system-for-read)
+ (if charset
+ (setq coding-system (intern (downcase charset)))
+ (setq coding-system 'utf-8)))
+ (insert (decode-coding-string plain coding-system))
+ (if (epg-context-result-for context 'verify)
+ (message "%s"
+ (epg-verify-result-to-string
+ (epg-context-result-for context 'verify)))))))))
+
(provide 'epa)
;;; epa.el ends here