This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-08-14
Channels
- # architecture (19)
- # beginners (3)
- # calva (2)
- # cherry (2)
- # clj-kondo (2)
- # clojure (58)
- # clojure-europe (15)
- # clojure-norway (1)
- # conjure (1)
- # data-oriented-programming (9)
- # data-science (10)
- # emacs (9)
- # hyperfiddle (1)
- # nbb (9)
- # off-topic (1)
- # shadow-cljs (24)
- # sql (14)
- # squint (58)
- # testing (13)
- # xtdb (10)
just doing this the other day and thought that this is where Java interop shines ... no mutability escapes the expression. Does this pattern of usage have a name?
(-> (doto (Signature/getInstance (if (string? algorithm) algorithm (name algorithm)))
(.initVerify public-key)
(.update data-bytes))
(.verify signature))
Beside the point, but I believe you can safely call name on a string, so you can get rid of the if expression
1
(let [data (.getBytes (pr-str edn-data-to-sign) "UTF-8")]
{:signature (-> (doto (Signature/getInstance "SHA256withECDSA" BouncyCastleProvider/PROVIDER_NAME)
(.initSign private-key)
(.update data))
(.sign))})
➕ 1
well, it has a thread too ( you really should learn how to read Clojure code and not rely so much on tools 😛 ) .... so that would be too minimal... thread-doto seems very German.