Liking cljdoc? Tell your friends :D

digest

net.clojars.savya/digest - A message digest library for Clojure. Providing md5, sha-256, HMAC, raw bytes, and base64 output.

Stack

Clojure GitHub Actions

Clojars Project cljdoc badge CI

There are several digest functions (such as md5, sha-256 ...) in this namespace. Each can handle the following input types:

  • java.lang.String
  • byte array
  • java.io.File
  • java.io.InputStream
  • Sequence of byte array

Usage

user=> (require '[clj-commons.digest :as digest])
nil
; On a string
user=> (digest/md5 "clojure")
"32c0d97f82a20e67c6d184620f6bd322"
; On a file
user=> (require '[clojure.java.io :as io])
nil
user=> (digest/sha-256 (io/file "/tmp/hello.txt"))
"163883d3e0e3b0c028d35b626b98564be8d9d649ed8adb8b929cb8c94c735c59"
; Raw bytes
user=> (seq (digest/digest-bytes "MD5" "clojure"))
(50 -64 -39 127 -126 -94 14 103 -58 -47 -124 98 15 107 -45 34)
; Base64
user=> (digest/digest-base64 "MD5" "clojure")
"MsDZf4KiDmfG0YRiD2vTIg=="
; HMAC
user=> (digest/hmac-sha-256 "secret" "message")
"8b5f48702995c1598c573db1e21866a9b825d4a794d169d7060a03605796360b"

Installation

deps.edn

net.clojars.savya/digest {:mvn/version "1.5.0"}

lein

[net.clojars.savya/digest "1.5.0"]

Dev

Run lein test to run the test suite.

Run bb dev/gen.clj after changing the generated static digest convenience functions.

Deployment

Run lein deploy clojars with clojars_username and clojars_password set. The password must be a Clojars deploy token, not the account password.

clojars_username=savya \
clojars_password="$(op item get Clojars --fields 'deploy token' --reveal)" \
lein deploy clojars

License

Copyright© 2017 Miki Tebeka miki.tebeka@gmail.com

Maintenance fork Copyright© 2026 Savya Sachi. Original: https://github.com/clj-commons/digest

Distributed under the Eclipse Public License (same as Clojure).

Snail image in tests is public domain by Miki Tebeka

Can you improve this documentation? These fine people already did:
Miki Tebeka, Michiel Borkent, Savyasachi, Erik Assum, Lauri Oherd & Dave Yarwood
Edit on GitHub

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close