Skip to content

Instantly share code, notes, and snippets.

@kubek2k
Last active February 26, 2025 19:45
Show Gist options
  • Save kubek2k/8446062 to your computer and use it in GitHub Desktop.
Save kubek2k/8446062 to your computer and use it in GitHub Desktop.

Revisions

  1. kubek2k revised this gist Aug 27, 2019. 1 changed file with 2 additions and 6 deletions.
    8 changes: 2 additions & 6 deletions sha256.clj
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,3 @@
    (defn sha256 [string]
    (let
    [md (java.security.MessageDigest/getInstance "SHA-256")
    byt (. string getBytes)
    digest (. md digest byt)]
    (clojure.string/join (map (fn [_] (Integer/toHexString (bit-and _ 0xFF))) digest)))
    )
    (let [digest (.digest (MessageDigest/getInstance "SHA-256") (.getBytes string "UTF-8"))]
    (apply str (map (partial format "%02x") digest))))
  2. kubek2k renamed this gist Jan 15, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.clj → sha256.clj
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    (defn- sha256 [string]
    (defn sha256 [string]
    (let
    [md (java.security.MessageDigest/getInstance "SHA-256")
    byt (. string getBytes)
  3. kubek2k renamed this gist Jan 15, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. kubek2k created this gist Jan 15, 2014.
    7 changes: 7 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    (defn- sha256 [string]
    (let
    [md (java.security.MessageDigest/getInstance "SHA-256")
    byt (. string getBytes)
    digest (. md digest byt)]
    (clojure.string/join (map (fn [_] (Integer/toHexString (bit-and _ 0xFF))) digest)))
    )