Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;; Easiest symmetric crypto for region of text.
- ;;
- ;; Mark start of region, move cursor to end of region, then
- ;; hit either M-f11 to encrypt, or M-f12 to decrypt.
- ;; Try alternating between both (without moving cursor) to
- ;; see the text morph from cleartext to encrypted text back
- ;; and forth.
- ;; After encrypting you can copy or kill without moving cursor.
- ;; Or after pasting encrypted into buffer, hit M-f12 to decrypt
- ;; since pasted region is already marked. Short, simple, easy.
- ;; Needed for below functions
- (require 'epg)
- ;; Encrypt region with default password
- (defun symmetric-encrypt-region (&optional n)
- "Encrypt region using symmetric crypto."
- (interactive "P")
- (let ((plain (delete-and-extract-region (point) (mark))))
- (insert-string (epg-encrypt-string (epg-make-context nil t) plain nil))))
- (global-set-key [M-f11] 'symmetric-encrypt-region)
- ;; Decrypt region with default password
- (defun symmetric-decrypt-region (&optional n)
- "Decrypt region using symmetric crypto."
- (interactive "P")
- (let ((cipher (delete-and-extract-region (point) (mark))))
- (insert-string (epg-decrypt-string (epg-make-context nil t) cipher))))
- (global-set-key [M-f12] 'symmetric-decrypt-region)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement