+(defvar rot13-translate-table
+ (let ((str (make-string 127 0))
+ (i 0))
+ (while (< i 127)
+ (aset str i i)
+ (setq i (1+ i)))
+ (setq i 0)
+ (while (< i 26)
+ (aset str (+ i ?a) (+ (% (+ i 13) 26) ?a))
+ (aset str (+ i ?A) (+ (% (+ i 13) 26) ?A))
+ (setq i (1+ i)))
+ str)
+ "String table for rot 13 translation.")
+
+;;;###autoload
+(defun rot13 (object &optional start end)
+ "Return Rot13 encryption of OBJECT, a buffer or string."
+ (if (bufferp object)
+ (with-current-buffer object
+ (rot13-region start end))
+ (rot13-string object)))
+
+;;;###autoload
+(defun rot13-string (string)
+ "Return Rot13 encryption of STRING."
+ (with-temp-buffer
+ (insert string)
+ (rot13-region (point-min) (point-max))
+ (buffer-string)))
+
+;;;###autoload
+(defun rot13-region (start end)
+ "Rot13 encrypt the region between START and END in current buffer."
+ (interactive "r")
+ (translate-region start end rot13-translate-table))
+