Skip to content

Instantly share code, notes, and snippets.

@vertexclique
Created April 22, 2012 12:39
Show Gist options
  • Save vertexclique/2463969 to your computer and use it in GitHub Desktop.
Save vertexclique/2463969 to your computer and use it in GitHub Desktop.
caesar-cipher-rot13
(defn caesar-en [c]
(let [i (int c)]
(cond
(or (and (>= i (int \a)) (<= i (int \m)))
(and (>= i (int \A)) (<= i (int \M))))
(char (+ i 3))
(or (and (>= i (int \n)) (<= i (int \z)))
(and (>= i (int \N)) (<= i (int \Z))))
(char (- i 3))
:else c)))
(defn caesar-enc[as]
(apply str (map caesar-en as)))
(defn caesar-dec[sa]
(apply str (map caesar-de sa)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment