This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-11-20
Channels
- # babashka (56)
- # beginners (151)
- # calva (3)
- # cider (31)
- # clj-kondo (17)
- # cljs-dev (5)
- # clojure (26)
- # clojure-australia (21)
- # clojure-dev (7)
- # clojure-europe (23)
- # clojure-nl (5)
- # clojure-spec (54)
- # clojure-uk (11)
- # clojuredesign-podcast (8)
- # clojurescript (77)
- # community-development (10)
- # core-typed (1)
- # cursive (3)
- # datomic (7)
- # docker (67)
- # emacs (10)
- # expound (6)
- # figwheel-main (3)
- # graalvm (67)
- # helix (10)
- # java (13)
- # jobs (6)
- # kaocha (4)
- # leiningen (15)
- # malli (2)
- # meander (31)
- # off-topic (40)
- # pedestal (9)
- # rdf (7)
- # reagent (5)
- # reitit (9)
- # remote-jobs (5)
- # shadow-cljs (94)
- # sql (7)
- # testing (12)
- # tools-deps (75)
- # vim (13)
Created a news page for babashka-related items: https://github.com/borkdude/babashka/blob/master/doc/news.md
@helios This question came up recently. The crypto
class for that is currently missing, but the person solved this by shelling out to openssl
Hey that was me!
(defn sign-with-string [key msg]
(-> (sh "openssl" "dgst" "-sha256" "-mac" "hmac" "-macopt" (str "key:" key) :in msg)
:out
str/trim))
(defn sign-with-hex [key msg]
(-> (sh "openssl" "dgst" "-sha256" "-mac" "hmac" "-macopt" (str "hexkey:" key) :in msg)
:out
str/trim))
I needed sha256 but I believe swapping in -sha1 is as easy as it sounds
annoying bit for me was knowing which bits support binary data and which are limited to string
you can pass bytes to sh
with :in
, which is cool, but I couldn’t figure out a way to pass bytes
in for a command option/flag (I had binary data that I wanted to use for a key
)
so I ended up hex-encoding my binary keys and passing as a string with sign-with-hex
there are probably ways to work around, perhaps by spinning up a file to hold the binary key, or maybe some fancy shell tricks to pipe in binary data
but this was good enough for me
Since there are now two people needing this, https://github.com/borkdude/babashka/issues/656 Please post which classes / Clojure examples should be needed for this
We could also make a small babashka.crypto namespace (or some other name) with util functions
posted an example! it’s java code 🙈
making classes available and (optionally) providing a small utility ns both sound solid to me
at a glance, buddy-core’s APIs look nice; adding that might be a good longer-term goal if it’s reasonably compatible I suspect @borkdude would have the best intuition for what’s a good fit or not 😁
(deftest Base64-test
(is (= "babashka"
(bb nil "(String. (.decode (java.util.Base64/getDecoder) (.encode (java.util.Base64/getEncoder) (.getBytes \"babashka\"))))"))))
I think I prefer the babashka.crypto namespace. There we can collect functions that are most frequently used for scripting. Instead of including buddy which can grow babashka bigger than necessary. Also offering babashka.crypto will help swapping out different implementations in the future.
can also shell out to shasum
if it’s just about hashing…
shasum -a 256 tests.edn
c0050533cb04ed9b5b3fc851b062830bac1c0c8f5569a3e4cec8bca9bb6dd54f tests.edn
@U5H74UNSF it's about getting the hmac-sha1 of a string given a specific key for API signature 😢
so I have this problem at hand: I've a 1.3G json file with stuff I need to feed an ElasticSearch instance with. The json itself contains a huuuuge JSON array. I'd like bb to lazily parse such array, chunk the contained objects into smaller batches then feed each batch to ES for ingestion
as in, when I try to reach into the internals of cheshire which I need to lazily parse the array, it fails to resolve names / classes (even the basic jackson classes)
@skuro afaik cheshire has an option to parse an array lazily, but I'm not sure if this works for an array that is embedded into something else
If the top-level object is an array, it will be parsed lazily (use `parse-strict' if strict parsing is required for top-level arrays.
oh, I see... I did json/parsed-seq
but json/parse
seems be be the only one doing lazy stuff
Is anyone using the smile functions from cheshire? I think I will remove them for the next release to free up 200kb from the binary, since I haven't seen anyone use them and I also don't use them myself. If there are any objections, I'll revert.
I'm curious, has anyone tried running buddy in babashka yet? I have need for doing some crypto stuff with it, and it would be convenient to be able to use bb
specifically, buddy.core.mac
buddy.core.codecs
and buddy.core.nonce
, to create an HMAC signature to pass to a curl call
it's funny that you mention this! hmac has been coming up two times earlier this week. it's in the air :) https://github.com/borkdude/babashka/issues/656
commented with my JVM code, will comment again with my openssl-calling code, if I can get it to work 🤞
I'd like to learn to use babashka to make http request. If you have some sample code or reference, would you please share. Thanks!
@yubrshen check out the docs here: https://github.com/borkdude/babashka.curl