       buffer))
 
   String
-  (make-digest [^String input ^Keyword alg]
-    (make-digest (->byte-array input) alg))
+  (digest* [^String input ^Keyword alg]
+    (digest* (->byte-array input) alg))
 
   java.io.InputStream
-  (make-digest [^java.io.InputStream input ^Keyword alg]
+  (digest* [^java.io.InputStream input ^Keyword alg]
     (let [digest  (resolve-digest alg)
           buffer1 (byte-array 5120)
           buffer2 (byte-array (.getDigestSize digest))]

      buffer2))

  java.io.File
  (make-digest [^java.io.File input ^Keyword alg]
    (make-digest (io/input-stream input) alg))

  java.net.URL
  (make-digest [^java.net.URL input ^Keyword alg]
    (make-digest (io/input-stream input) alg))

  java.net.URI
  (make-digest [^java.net.URI input ^Keyword alg]
    (make-digest (io/input-stream input) alg)))

(defn digest
  "Generic function for create cryptographic hash."
  [input ^Keyword alg]
  (make-digest input alg))

(def sha256 #(digest % :sha256))
(def sha384 #(digest % :sha384))

   (instance? IFn alg) (alg)
   (instance? Digest alg) alg))

(defprotocol IDigest
  (^:private digest* [input algorithm] "Low level interface, always returns bytes"))

(extend-protocol IDigest
  (Class/forName "[B")
  (digest* [^bytes input ^Keyword alg]
    (let [digest (resolve-digest alg)
          buffer (byte-array (.getDigestSize digest))]
      (.update digest input 0 (count input))
