 (ns caesium.crypto.generichash
   (:refer-clojure :exclude [bytes hash])
-  (:require [caesium.binding :refer [sodium defconsts]]))
+  (:require [caesium.binding :refer [sodium defconsts]]
+            [caesium.byte-bufs :refer [buflen]]))
 
 (defconsts [bytes
             bytes-min

     (let [salt (or salt (byte-array blake2b-saltbytes))
           personal (or personal (byte-array blake2b-personalbytes))]
       (.crypto_generichash_blake2b_salt_personal
        sodium
        buf (alength ^bytes buf)
        msg (alength ^bytes msg)
        key (alength ^bytes key)
        salt personal))
     (.crypto_generichash_blake2b
      sodium
      buf (alength ^bytes buf)
      msg (alength ^bytes msg)
      key (alength ^bytes key)))
   buf))

(defn blake2b

  ([buf msg {:keys [key]
             :or {key (byte-array 0)}}]
   (.crypto_generichash
    sodium buf (buflen buf) msg (buflen msg) key (buflen key))))

(defn hash
  "A friendlier API for generichash.
