Convert Data to Base64 and back in a reasonable amount of time.
This is at least as fast as the Apache Commons Base64 Codec (whose just-as-simple usage you can see here).
Leiningen
[base64-clj "0.1.1"]
REPL
(require '[base64-clj.core :as base64])
(base64/encode "Hello, World!")
;; => "SGVsbG8sIFdvcmxkIQ=="
(base64/decode "SGVsbG8sIFdvcmxkIQ==")
;; => "Hello, World!"
(base64/encode-bytes (.getBytes "Hello, World!"))
;; => #<byte[] [B@28a34522>
(base64/decode-bytes (.getBytes "SGVsbG8sIFdvcmxkIQ=="))
;; => #<byte[] [B@18b0af83>
(base64/encode "ÄÖÜ" "ISO-8859-1")
;; => "xNbc"
(base64/encode "ÄÖÜ" "UTF-8")
;; => "w4TDlsOc"
(base64/decode "xNbc")
;; => "???"
(base64/decode "xNbc" "ISO-8859-1")
;; => "ÄÖÜ"
You can run Midje tests using the following Leiningen command:
lein midje
You can run Criterium benchmarks on different Base64 codecs with the following Leiningen command:
lein benchmark base64-clj-benchmark.<ID> [--quick]
ID is one of:
base64-clj
: evaluate this projectbase64-naive
: evaluate a naive and intuitive implementationapache-commons-base64
: evaluate the Apache Commons CodecCopyright © Yannick Scherer
Distributed under the Eclipse Public License, the same as Clojure.
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close