Clojure base64 encoding

后端 未结 6 1884
深忆病人
深忆病人 2020-12-09 17:31

I want something as simple as \"string\" -> base64. With the older base64.encode-str it was easy (and sounded \"more clojure\", but the newer clojure.data.codec.base64

6条回答
  •  借酒劲吻你
    2020-12-09 17:50

    Possible duplicate of Clojure equivalent of python's base64 encode and decode

    The Tupelo library has Clojure wrappers around the base Java Base64 and Base64Url functionality. A look at the unit tests show the code in action:

    (ns tst.tupelo.base64
      (:require [tupelo.base64 :as b64] ))
    
    code-str    (b64/encode-str  orig)
    result      (b64/decode-str  code-str) ]
    (is (= orig result))
    

    where the input & output values are plain strings (there is also a variant for byte arrays).

    The API docs are here.

提交回复
热议问题