# Ruby
# v1
->(x, s) { s.tr (0..25).map { |n| [(n+65).chr, (n+97).chr] }.flatten.join, (0..25).map { |n| [((n+x)%26+65).chr, ((n+x)%26+97).chr] }.flatten.join }
# v2
->(x, s) { (->(a) { s.tr a.join, (a*2).drop((x%26)*2).take(52).join })[(0..25).map{|n| [(n+65).chr, (n+97).chr]}.flatten] }
;; Clojure
;; v1
(fn [x s] (#(apply str (map % s)) (#(zipmap % (drop (* 2 (mod x 26)) (cycle %))) (mapcat (juxt #(char (+ 65 %)) #(char (+ 97 %))) (range 26)))))
;; v2
;; Given: (defn tr [s a b] (let [tran (zipmap a b)] (apply str (map #(tran % %) s))))
(fn [x s] (#(tr s % (drop (* 2 (mod x 26)) (cycle %))) (mapcat (juxt #(char (+ 65 %)) #(char (+ 97 %))) (range 26))))
Wow probably more secure than aes. Liked the first version better.:)