Skip to content

Instantly share code, notes, and snippets.

@sysr-q
Created June 29, 2013 01:31
Show Gist options
  • Save sysr-q/5889275 to your computer and use it in GitHub Desktop.
Save sysr-q/5889275 to your computer and use it in GitHub Desktop.
Random junk I throw together in Clojure.
(def in "5d41402abc4b2a76b9719d911017c592")
(def res "5d:41:40:2a:bc:4b:2a:76:b9:71:9d:91:10:17:c5:92")
; python => ':'.join(a+b for a,b in zip(a[::2], a[1::2]))
; (clojure.string/join ":" (map (fn [x] (clojure.string/join "" x)) (partition 2 s)))
(defn md5 [x] x)
(defn hash-to-fingerprint [k]
(defn shrink [x] (clojure.string/join "" x))
(clojure.string/join ":"
(map shrink (partition 2 (md5 k)))))
(= (hash-to-fingerprint s) res)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment