Back

blake2b (clj)

(source)

function

(blake2b input length)
BLAKE2 is a cryptographic hash function faster than MD5, SHA-1, SHA-2, and SHA-3, yet is at least as secure as the latest standard SHA-3.

Examples

funcool/buddy-core
(ns buddy.core.hash-tests
  (:require [clojure.test :refer :all]
            [clojure.string :as str]
            [buddy.core.codecs :as codecs :refer :all]
            [buddy.core.bytes :as bytes]
            [buddy.core.keys :refer :all]
            [buddy.core.hash :as hash]
            [clojure.java.io :as io]))

  (testing "blake2 512"
    (let [hashed1 (hash/blake2b-512 "")
          hashed2 (hash/blake2b "" 64)
          hashed3 (hash/digest "" :blake2b-512)]
      (is (bytes/equals? hashed1 hashed2))
      (is (bytes/equals? hashed1 hashed3))
      (is (= (str/upper-case (bytes->hex hashed1))
             (str "786A02F742015903C6C6FD852552D272"
                  "912F4740E15847618A86E217F71F5419"
                  "D25E1031AFEE585313896444934EB04B"
                  "903A685B1448B755D56F701AFE9BE2CE")))))