Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defn hmacSHA256
- (memoize (fn [payload secret]
- (let [mac (Mac/getInstance "HMACSHA256")
- secretKey (SecretKeySpec. (.getBytes secret) (.getAlgorithm mac))
- byteResult (-> (doto mac
- (.init secretKey))
- (.doFinal (.getBytes payload)))
- stringResult (->> byteResult
- (map #(format "%x" %))
- (apply str))]
- stringResult))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement