Browse Source

md5 hash compuation bug fixed

master
Christian Mueller 12 years ago
parent
commit
c1519668ed
  1. 5
      src/notehub/storage.clj
  2. 2
      test/notehub/test/storage.clj

5
src/notehub/storage.clj

@ -12,7 +12,10 @@ @@ -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

2
test/notehub/test/storage.clj

@ -15,6 +15,8 @@ @@ -15,6 +15,8 @@
:header-font "Anton"})
(def test-short-url "")
(deftest signature
(is (= "07e1c0d9533b5168e18a99f4540448af" (sign "wwq123456"))))
(deftest storage
(testing "Storage"

Loading…
Cancel
Save