plain text hidden behind a function call (to make localization easier)
This commit is contained in:
@@ -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)))
|
||||
|
||||
Reference in New Issue
Block a user