Skip to content

Instantly share code, notes, and snippets.

@wasamasa
Last active April 8, 2016 15:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wasamasa/7f92676a8f01e6cbbb7851e2d089ce13 to your computer and use it in GitHub Desktop.
Save wasamasa/7f92676a8f01e6cbbb7851e2d089ce13 to your computer and use it in GitHub Desktop.
Buffer obfuscation
(defvar my-buffer-obfuscation-overlay nil)
(defun my-obfuscate-buffer ()
(interactive)
(let* ((buffer-content (buffer-substring (point-min) (point-max))))
(dotimes (i (length buffer-content))
(let ((char (aref buffer-content i)))
(when (string-match-p "[[:graph:]]" (char-to-string char))
(aset buffer-content i ?.))))
(setq my-buffer-obfuscation-overlay
(make-overlay (point-min) (point-max)))
(overlay-put my-buffer-obfuscation-overlay
'display buffer-content)))
(defun my-unobfuscate-buffer ()
(interactive)
(when my-buffer-obfuscation-overlay
(delete-overlay my-buffer-obfuscation-overlay)
(setq my-buffer-obfuscation-overlay nil)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment