From c1519668edaf0fbb047dd4983b06b770c62ca091 Mon Sep 17 00:00:00 2001 From: Christian Mueller Date: Mon, 17 Feb 2014 23:18:47 +0100 Subject: [PATCH] md5 hash compuation bug fixed --- src/notehub/storage.clj | 5 ++++- test/notehub/test/storage.clj | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/notehub/storage.clj b/src/notehub/storage.clj index 79b7c0b..2cce38a 100644 --- a/src/notehub/storage.clj +++ b/src/notehub/storage.clj @@ -12,7 +12,10 @@ (let [input (sreplace (apply str args) #"[\r\n]" "")] (do (.reset md5Instance) (.update md5Instance (.getBytes input)) - (.toString (new java.math.BigInteger 1 (.digest md5Instance)) 16))))) + (apply str + (map #(let [c (Integer/toHexString (bit-and 0xff %))] + (if (= 1 (count c)) (str "0" c) c)) + (.digest md5Instance))))))) (defmacro redis [cmd & body] `(car/wcar conn diff --git a/test/notehub/test/storage.clj b/test/notehub/test/storage.clj index 8b0a0ad..4456178 100644 --- a/test/notehub/test/storage.clj +++ b/test/notehub/test/storage.clj @@ -15,6 +15,8 @@ :header-font "Anton"}) (def test-short-url "") +(deftest signature + (is (= "07e1c0d9533b5168e18a99f4540448af" (sign "wwq123456")))) (deftest storage (testing "Storage"