From 2d2d32ada3b792c0ea1cdd0d1b5dbb6c5ab08b58 Mon Sep 17 00:00:00 2001 From: hmurata Date: Wed, 20 Dec 2006 12:40:29 +0000 Subject: [PATCH] (epa--format-fingerprint-1): New function. (epa--format-fingerprint): Ditto. (epa--show-key): Use it. --- ChangeLog | 6 ++++++ epa.el | 22 +++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index a68579f..fea04e2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-12-20 Hiroya Murata + + * epa.el (epa--format-fingerprint-1): New function. + (epa--format-fingerprint): Ditto. + (epa--show-key): Use it. + 2006-12-20 Daiki Ueno * epa-file.el (epa-file-write-region): Don't attempt to write the diff --git a/epa.el b/epa.el index 1a84de3..2dab9a1 100644 --- a/epa.el +++ b/epa.el @@ -464,6 +464,26 @@ If SECRET is non-nil, list secret keys instead of public keys." (delete-window (get-buffer-window epa-keys-buffer))) (kill-buffer epa-keys-buffer)))) +(defun epa--format-fingerprint-1 (fingerprint unit-size block-size) + (let ((unit 0)) + (with-temp-buffer + (insert fingerprint) + (goto-char (point-min)) + (while (progn + (goto-char (+ (point) unit-size)) + (not (eobp))) + (setq unit (1+ unit)) + (insert (if (= (% unit block-size) 0) " " " "))) + (buffer-string)))) + +(defun epa--format-fingerprint (fingerprint) + (if fingerprint + (if (= (length fingerprint) 40) + ;; 1234 5678 9ABC DEF0 1234 5678 9ABC DEF0 1234 5678 + (epa--format-fingerprint-1 fingerprint 4 5) + ;; 12 34 56 78 9A BC DE F0 12 34 56 78 9A BC DE F0 + (epa--format-fingerprint-1 fingerprint 2 8)))) + (defun epa--show-key (key) (let* ((primary-sub-key (car (epg-key-sub-key-list key))) (entry (assoc (epg-sub-key-id primary-sub-key) @@ -527,7 +547,7 @@ If SECRET is non-nil, list secret keys instead of public keys." (epg-sub-key-capability (car pointer)) " ") "\n\tFingerprint: " - (epg-sub-key-fingerprint (car pointer)) + (epa--format-fingerprint (epg-sub-key-fingerprint (car pointer))) "\n") (setq pointer (cdr pointer))) (goto-char (point-min)) -- 1.7.10.4