(message "Encrypting %s...done" (file-name-nondirectory file))))
;;;###autoload
+(defun epa-decrypt-region (start end)
+ "Decrypt the current region between START and END."
+ (interactive "r")
+ (save-excursion
+ (let ((context (epg-make-context))
+ charset plain coding-system)
+ (message "Decrypting...")
+ (setq plain (epg-decrypt-string context
+ (buffer-substring start end)))
+ (message "Decrypting...done")
+ (delete-region start end)
+ (goto-char start)
+ (insert (decode-coding-string plain coding-system-for-read))
+ (if (epg-context-result-for context 'verify)
+ (message "%s"
+ (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."
(interactive "r")
(goto-char armor-start)
(if (re-search-forward "^Charset: \\(.*\\)" armor-end t)
(setq charset (match-string 1)))
- (message "Decrypting...")
- (setq plain (epg-decrypt-string
- (epg-make-context)
- (buffer-substring armor-start armor-end)))
- (message "Decrypting...done")
- (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)))))))))
+ (let ((coding-system-for-read coding-system))
+ (epa-decrypt-region start end)))))))
+
+;;;###autoload
+(defun epa-verify-region (start end)
+ "Verify the current region between START and END."
+ (interactive "r")
+ (let ((context (epg-make-context)))
+ (epg-verify-string context
+ (encode-coding-string
+ (buffer-substring start end)
+ coding-system-for-write))
+ (message "%s"
+ (epg-verify-result-to-string
+ (epg-context-result-for context 'verify)))))
;;;###autoload
(defun epa-verify-armor-in-region (start end)
nil t)))
(unless armor-end
(error "No armor tail"))
- (epg-verify-string (epg-make-context)
- (encode-coding-string
- (buffer-substring armor-start armor-end)
- coding-system-for-write))
- (message "%s"
- (epg-verify-result-to-string
- (epg-context-result-for context 'verify))))))))
+ (epa-verify-region armor-start armor-end))))))
;;;###autoload
(defun epa-sign-region (start end signers mode)