plain text hidden behind a function call (to make localization easier)

This commit is contained in:
Christian Mueller
2012-06-13 20:24:30 +02:00
parent 1ba9dc5121
commit 01754a7d57
8 changed files with 102 additions and 73 deletions
+5 -4
View File
@@ -4,15 +4,16 @@
(defn hash
"A simple hash-function, which computes a hash from the text field
content and given session number. It is intended to be used as a spam
protection / captcha alternative. (Probably doesn't work for URF-16)"
protection / captcha alternative (let's see whether spambots evaluate heavy JS).
(Probably doesn't work for UTF-16)"
[f s]
(let [short-mod #(mod % 32767)
char-codes (map f
(filter #(not (contains? #{"\n" "\r"} %)) (map str s)))]
char-codes (map f (remove #(contains? #{"\n" "\r"} %) (map str s)))
zip-with-index (map list char-codes (range))]
(reduce
#(short-mod (+ %
(short-mod (* (first %2)
((if (odd? %)
bit-xor
bit-and) 16381 (second %2))))))
0 (map list char-codes (range)))))
0 zip-with-index)))