Anonymous avatar Anonymous committed e545570 Merge

Merge protocol switch with upstream

Comments (0)

Files changed (9)

 digest-*.jar
 lib
 pom.xml
+.lein-*
+target
 23e9fa7f1ac8f3e1b130a48de147231b4c97d914 1.3.0
 23e9fa7f1ac8f3e1b130a48de147231b4c97d914 1.3.0
 3ebc187532835c3804e326b75e71768233ebaf68 1.3.0
+c9dc449f535c5e0e362bcaab5647df430533d14b 1.4.1
+05f938662bd5a3c122d705fecc97f04e209d0613 1.4.2
+language: clojure
+2012-11-24 version 1.4.2
+    * Clojure 1.4
+
+2012-11-24 version 1.4.1
+    * Fix file descriptor leak (thanks Craig Ludington)
+
+2012-03-04 version 1.4.0
+    * Remove reflections (thanks naitik!)
+
 2011-10-03 version 1.3.0
     * Clojure 1.3.0
     * def ^:dynamic
 ============
 Add `[digest "1.3.0"]` to your `project.clj`
 
+Builds
+======
+http://travis-ci.org/#!/tebeka/clj-digest
+
 License
 =======
-Copyright (C) 2011 Miki Tebeka <miki.tebeka@gmail.com>
+Copyright (C) 2012 Miki Tebeka <miki.tebeka@gmail.com>
 
 Distributed under the Eclipse Public License, the same as Clojure.
-(defproject digest "1.3.0"
+(defproject digest "1.4.2"
   :description "Digest algorithms (MD5, SHA ...) for Clojure"
   :author "Miki Tebeka <miki.tebeka@gmail.com>"
   :url "https://bitbucket.org/tebeka/clj-digest/src"
-  :dependencies [[org.clojure/clojure "1.3.0"]])
+  :dependencies [[org.clojure/clojure "1.4.0"]])

push-to-clojars.sh

+#!/bin/bash
+# Push to clojars
+
+set -x
+set -e
+
+if [ ! -f project.clj ]; then
+    echo "error: can't find project.clj" 1>&2
+    exit 1
+fi
+
+project=$(grep defproject project.clj | awk '{print $2}')
+version=$(egrep -o "[0-9]+\.[0-9]+\.[0-9]+(-SNAPSHOT)?" project.clj  | head -1)
+jar=target/$project-${version}.jar
+
+if [ -f $jar ]; then
+    rm $jar
+fi
+lein jar
+lein pom
+scp pom.xml $jar clojars@clojars.org:
+rm pom.xml $jar

push.sh

-#!/bin/bash
-# Push to clojars
-
-set -x
-set -e
-
-if [ ! -f project.clj ]; then
-    echo "error: can't find project.clj" 1>&2
-    exit 1
-fi
-
-project=$(grep defproject project.clj | awk '{print $2}')
-version=$(egrep -o "[0-9]+\.[0-9]+\.[0-9]+(-SNAPSHOT)?" project.clj  | head -1)
-jar=$project-${version}.jar
-
-if [ -f $jar ]; then
-    rm $jar
-fi
-lein jar
-lein pom
-scp pom.xml $jar clojars@clojars.org:
-rm pom.xml $jar
       :doc "Message digest algorithms for Clojure"}
   (:use [clojure.string :only (split lower-case)])
   (:import java.util.Arrays
-           (java.security MessageDigest Security)
+           (java.security MessageDigest Security Provider)
            (java.io FileInputStream File InputStream)))
 
 ; Default buffer size for reading
 (def ^:dynamic *buffer-size* 1024)
 
-(defn- read-some 
+(defn- read-some
   "Read some data from reader. Return [data size] if there's more to read,
   otherwise nil."
-  [reader]
-  (let [buffer (make-array Byte/TYPE *buffer-size*)
+  [^InputStream reader]
+  (let [^bytes  buffer (make-array Byte/TYPE *buffer-size*)
         size (.read reader buffer)]
     (when (> size 0)
       (if (= size *buffer-size*) buffer (Arrays/copyOf buffer size)))))
 
 (defn- byte-seq
   "Return a sequence of [data size] from reader."
-  [reader]
+  [^InputStream reader]
   (take-while (complement nil?) (repeatedly (partial read-some reader))))
 
 (defn- signature
   "Get signature (string) of digest."
-  [algorithm]
+  [^MessageDigest algorithm]
   (let [size (* 2 (.getDigestLength algorithm))
         sig (.toString (BigInteger. 1 (.digest algorithm)) 16)
         padding (apply str (repeat (- size (count sig)) "0"))]
   ;; * http://www.holygoat.co.uk/blog/entry/2009-03-26-1
   ;; * http://www.rgagnon.com/javadetails/java-0416.html 
   (-digest [message algorithm]
-    (let [algo (MessageDigest/getInstance algorithm)]
+    (let [^MessageDigest algo (MessageDigest/getInstance algorithm)]
       (.reset algo)
-      (doseq [chunk message] (.update algo chunk))
+      (doseq [^bytes b message] (.update algo b))
       (signature algo)))
 
   String
   (-digest [message algorithm]
     (-digest [(.getBytes message)] algorithm))
   
-  
-
   InputStream
   (-digest [reader algorithm]
     (-digest (byte-seq reader) algorithm))
   
   File
   (-digest [file algorithm]
-    (-digest (FileInputStream. file) algorithm))
+    (with-open [f (FileInputStream. file)]
+      (-digest algorithm f)))
 
   nil
   (-digest [message algorithm]
 (defn algorithms []
   "List support digest algorithms."
   (let [providers (into [] (Security/getProviders))
-        names (mapcat #(enumeration-seq (.keys %)) providers)
+        names (mapcat (fn [^Provider p] (enumeration-seq (.keys p))) providers)
         digest-names (filter #(re-find #"MessageDigest\.[A-Z0-9-]+$" %) names)]
     (set (map #(last (split % #"\.")) digest-names))))
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.