+ (epg-encrypt-file context file recipients cipher)
+ (message "Encrypting %s...wrote %s" (file-name-nondirectory file)
+ (file-name-nondirectory cipher))))
+
+;;;###autoload
+(defun epa-decrypt-region (start end)
+ "Decrypt the current region between START and END.
+
+Don't use this command in Lisp programs!"
+ (interactive "r")
+ (save-excursion
+ (let ((context (epg-make-context epa-protocol))
+ plain)
+ (epg-context-set-passphrase-callback context
+ #'epa-passphrase-callback-function)
+ (epg-context-set-progress-callback context
+ #'epa-progress-callback-function)
+ (message "Decrypting...")
+ (setq plain (epg-decrypt-string context (buffer-substring start end)))
+ (message "Decrypting...done")
+ (delete-region start end)
+ (goto-char start)
+ (insert (epa--decode-coding-string plain
+ (or coding-system-for-read
+ (get-text-property
+ start 'epa-coding-system-used))))
+ (if (epg-context-result-for context 'verify)
+ (epa-display-info (epg-verify-result-to-string
+ (epg-context-result-for context 'verify)))))))
+
+;;;###autoload
+(defun epa-decrypt-armor-in-region (start end)
+ "Decrypt OpenPGP armors in the current region between START and END.
+
+Don't use this command in Lisp programs!"
+ (interactive "r")
+ (save-excursion
+ (save-restriction
+ (narrow-to-region start end)
+ (goto-char start)
+ (let (armor-start armor-end charset 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: \\(.*\\)" armor-end t)
+ (setq charset (match-string 1)))
+ (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)))
+ (let ((coding-system-for-read coding-system))
+ (epa-decrypt-region start end)))))))
+
+(if (fboundp 'select-safe-coding-system)
+ (defalias 'epa--select-safe-coding-system 'select-safe-coding-system)
+ (defun epa--select-safe-coding-system (from to)
+ buffer-file-coding-system))
+
+;;;###autoload
+(defun epa-verify-region (start end)
+ "Verify the current region between START and END.
+
+Don't use this command in Lisp programs!"
+ (interactive "r")
+ (let ((context (epg-make-context epa-protocol)))
+ (epg-context-set-progress-callback context
+ #'epa-progress-callback-function)
+ (epg-verify-string context
+ (epa--encode-coding-string
+ (buffer-substring start end)
+ (or coding-system-for-write
+ (get-text-property start
+ 'epa-coding-system-used))))
+ (if (epg-context-result-for context 'verify)
+ (epa-display-info (epg-verify-result-to-string
+ (epg-context-result-for context 'verify))))))
+
+;;;###autoload
+(defun epa-verify-cleartext-in-region (start end)
+ "Verify OpenPGP cleartext signed messages in the current region
+between START and END.