Now that Emacs has encryption functions built-in (previously, an external library had to be added), you can use GnuPG to keep all your sensitive data secret. Still, there isn’t an easy way to tell Emacs to treat a whole file as encrypted. So I rewrote mc-gpg-file-mode.el from emacswiki to use the built-in emacs functions. Here it is (non-colorized version on emacswiki):

  (defvar pgg-gpg-user-id "YOUR-ID-HERE")  (autoload 'pgg-make-temp-file "pgg" "PGG")  (autoload 'pgg-gpg-decrypt-region "pgg-gpg" "PGG GnuPG")  (define-generic-mode 'gpg-file-mode    (list ?#)     nil nil    '(".gpg\\'" ".gpg-encrypted\\'")    (list (lambda ()              (add-hook 'before-save-hook                        (lambda ()                           (let ((pgg-output-buffer (current-buffer)))                            (pgg-gpg-encrypt-region (point-min) (point-max)                                                    (list pgg-gpg-user-id))))                        nil t)              (add-hook 'after-save-hook                         (lambda ()                          (let ((pgg-output-buffer (current-buffer)))                            (pgg-gpg-decrypt-region (point-min) (point-max)))                          (set-buffer-modified-p nil)                          (auto-save-mode nil))                        nil t)              (let ((pgg-output-buffer (current-buffer)))                (pgg-gpg-decrypt-region (point-min) (point-max)))              (auto-save-mode nil)              (set-buffer-modified-p nil)))    "Mode for gpg encrypted files")  
 | Posted by | Categories: Uncategorized |

For the past month or so, I’ve been doing some consulting with IntraHealth. We’re about to release a sizable webapp under the GPLv3 and one of the tasks is adding the proper headers to the files. Oh, of note, the Free Software Foundation has entered the age of the web. Instead of telling you to “write to the FSF at…”, if you need a copy of the full license, you are told to visit http://www.gnu.org/licenses/. Anyway, there seems to be a real lack of tools to help with this. Sure, there is this ruby script from Xavier Hanin, a one off and, finally, this Perl script. None of these supports PHP. So I grabbed the Perl script, made a couple of changes to add support for the GPLv3 and PHP. Here it is. The tool could really use a lot of improvement. More file types, more licenses, better detection, etc. But, for now, it’ll do.

 | Posted by | Categories: Uncategorized |