Advertisement
Guest User

Untitled

a guest
Dec 18th, 2014
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. (defn hmacSHA256
  2. (memoize (fn [payload secret]
  3. (let [mac (Mac/getInstance "HMACSHA256")
  4. secretKey (SecretKeySpec. (.getBytes secret) (.getAlgorithm mac))
  5. byteResult (-> (doto mac
  6. (.init secretKey))
  7. (.doFinal (.getBytes payload)))
  8. stringResult (->> byteResult
  9. (map #(format "%x" %))
  10. (apply str))]
  11. stringResult))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement