[Git][clojure-team/clj-digest-clojure][upstream] New upstream version 1.4.9+dfsg
Louis-Philippe Véronneau
gitlab at salsa.debian.org
Thu Dec 17 22:13:11 GMT 2020
Louis-Philippe Véronneau pushed to branch upstream at Debian Clojure Maintainers / clj-digest-clojure
Commits:
2f0419b2 by Louis-Philippe Véronneau at 2020-12-10T15:49:34-05:00
New upstream version 1.4.9+dfsg
- - - - -
10 changed files:
- .hgignore → .gitignore
- − .hgtags
- ChangeLog
- + Makefile
- README.md
- project.clj
- − push-to-clojars.sh
- src/digest.clj
- − test/clojure.png
- test/digest_test.clj
Changes:
=====================================
.hgignore → .gitignore
=====================================
@@ -1,9 +1,8 @@
-syntax: glob
-
+.lein-*
README.html
classes
digest-*.jar
lib
pom.xml
-.lein-*
+pom.xml.asc
target
=====================================
.hgtags deleted
=====================================
@@ -1,11 +0,0 @@
-75060291f6a6771f6a7fd45eec7417db3f5bbff5 1.1.0
-59789123e3f9d5d54d204d7e9885158227abe51e 1.1.1
-3a1f9492f43ff37b7140c6fd18be61ce483f88ed 1.2.0
-f3896701371ef1f2a353d8261555a06234b6c652 1.2.1
-23e9fa7f1ac8f3e1b130a48de147231b4c97d914 1.3.0
-23e9fa7f1ac8f3e1b130a48de147231b4c97d914 1.3.0
-3ebc187532835c3804e326b75e71768233ebaf68 1.3.0
-c9dc449f535c5e0e362bcaab5647df430533d14b 1.4.1
-05f938662bd5a3c122d705fecc97f04e209d0613 1.4.2
-1d9208f7c8bd5f9bf4a7e3b244fba479642a0229 1.4.3
-f9d486aa099478aa1b1058831b224aca5618f92f 1.4.4
=====================================
ChangeLog
=====================================
@@ -1,26 +1,36 @@
+2018-03-25 version 1.4.8
+* Minor fixes (@laurio in PR #8)
+
+2018-03-18 version 1.4.7
+* Minor simplifications, fix typo.
+* Clojure 1.9.0
+
+2016-08-18 version 1.4.6
+* Include standard function metadata on digest functions (@holguinj in PR #6)
+
2016-06-16 version 1.4.5
- * Added licence to project.clj (@raxod502 in PR #4)
- * Clojure 1.8.0
+* Added licence to project.clj (@raxod502 in PR #4)
+* Clojure 1.8.0
2014-04-02 version 1.4.4
- * Clojure 1.6
- * README.rst -> README.md
+* Clojure 1.6
+* README.rst -> README.md
2013-02-20 version 1.4.3
- * Using protocols (thanks DerGuteMoritz)
+* Using protocols (thanks DerGuteMoritz)
2012-11-24 version 1.4.2
- * Clojure 1.4
+* Clojure 1.4
2012-11-24 version 1.4.1
- * Fix file descriptor leak (thanks Craig Ludington)
+* Fix file descriptor leak (thanks Craig Ludington)
2012-03-04 version 1.4.0
- * Remove reflections (thanks naitik!)
+* Remove reflections (thanks naitik!)
2011-10-03 version 1.3.0
- * Clojure 1.3.0
- * def ^:dynamic
+* Clojure 1.3.0
+* def ^:dynamic
2011-02-27 version 1.2.1
- * Fixed bug in signature padding
+* Fixed bug in signature padding
=====================================
Makefile
=====================================
@@ -0,0 +1,10 @@
+all:
+ $(error please pick a target)
+
+test:
+ lein test
+
+publish:
+ lein deploy clojars-https
+
+.PHONY: all test publish
=====================================
README.md
=====================================
@@ -4,7 +4,7 @@
`digest` - Message digest library for Clojure. Providing md5, sha-256, ...
-There are several digest function (such as `md5`, `sha-256` ...) in this
+There are several digest functions (such as `md5`, `sha-256` ...) in this
namespace. Each can handle the following input types:
* java.lang.String
@@ -27,9 +27,9 @@ namespace. Each can handle the following input types:
"163883d3e0e3b0c028d35b626b98564be8d9d649ed8adb8b929cb8c94c735c59"
# Installation
-Add `[digest "1.4.4"]` to your `project.clj`.
+Add `[digest "1.4.9"]` to your `project.clj`.
# License
-Copyright© 2016 Miki Tebeka <miki.tebeka at gmail.com>
+Copyright© 2017 Miki Tebeka <miki.tebeka at gmail.com>
Distributed under the Eclipse Public License (same as Clojure).
=====================================
project.clj
=====================================
@@ -1,7 +1,7 @@
-(defproject digest "1.4.5"
+(defproject digest "1.4.9"
:description "Digest algorithms (MD5, SHA ...) for Clojure"
:author "Miki Tebeka <miki.tebeka at gmail.com>"
- :url "https://bitbucket.org/tebeka/clj-digest/src"
+ :url "https://github.com/tebeka/clj-digest"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
- :dependencies [[org.clojure/clojure "1.8.0"]])
+ :dependencies [[org.clojure/clojure "1.10.0"]])
=====================================
push-to-clojars.sh deleted
=====================================
@@ -1,22 +0,0 @@
-#!/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 at clojars.org:
-rm pom.xml $jar
=====================================
src/digest.clj
=====================================
@@ -1,10 +1,11 @@
-(ns digest
- #^{ :author "Miki Tebeka <miki.tebeka at gmail.com>"
- :doc "Message digest algorithms for Clojure"}
- (:use [clojure.string :only (split lower-case)])
- (:import java.util.Arrays
- (java.security MessageDigest Security Provider)
- (java.io FileInputStream File InputStream)))
+(ns
+ ^{:author "Miki Tebeka <miki.tebeka at gmail.com>"
+ :doc "Message digest algorithms for Clojure"}
+ digest
+ (:require [clojure.string :refer [join lower-case split]])
+ (:import (java.io File FileInputStream InputStream)
+ (java.security MessageDigest Provider Security)
+ (java.util Arrays)))
; Default buffer size for reading
(def ^:dynamic *buffer-size* 1024)
@@ -13,22 +14,22 @@
"Read some data from reader. Return [data size] if there's more to read,
otherwise nil."
[^InputStream reader]
- (let [^bytes buffer (make-array Byte/TYPE *buffer-size*)
+ (let [^bytes buffer (make-array Byte/TYPE *buffer-size*)
size (.read reader buffer)]
- (when (> size 0)
+ (when (pos? size)
(if (= size *buffer-size*) buffer (Arrays/copyOf buffer size)))))
(defn- byte-seq
"Return a sequence of [data size] from reader."
[^InputStream reader]
- (take-while (complement nil?) (repeatedly (partial read-some reader))))
+ (take-while some? (repeatedly (partial read-some reader))))
(defn- signature
"Get signature (string) of digest."
[^MessageDigest algorithm]
(let [size (* 2 (.getDigestLength algorithm))
sig (.toString (BigInteger. 1 (.digest algorithm)) 16)
- padding (apply str (repeat (- size (count sig)) "0"))]
+ padding (join (repeat (- size (count sig)) "0"))]
(str padding sig)))
(defprotocol Digestible
@@ -36,13 +37,13 @@
(extend-protocol Digestible
(class (make-array Byte/TYPE 0))
- (-digest [message algorithm]
+ (-digest [message algorithm]
(-digest [message] algorithm))
-
+
java.util.Collection
- ;; Code "borrowed" from
+ ;; Code "borrowed" from
;; * http://www.holygoat.co.uk/blog/entry/2009-03-26-1
- ;; * http://www.rgagnon.com/javadetails/java-0416.html
+ ;; * http://www.rgagnon.com/javadetails/java-0416.html
(-digest [message algorithm]
(let [^MessageDigest algo (MessageDigest/getInstance algorithm)]
(.reset algo)
@@ -52,11 +53,11 @@
String
(-digest [message algorithm]
(-digest [(.getBytes message)] algorithm))
-
+
InputStream
(-digest [reader algorithm]
(-digest (byte-seq reader) algorithm))
-
+
File
(-digest [file algorithm]
(with-open [f (FileInputStream. file)]
@@ -71,18 +72,31 @@
[algorithm message]
(-digest message algorithm))
-(defn algorithms []
+(defn algorithms
"List support digest algorithms."
- (let [providers (into [] (Security/getProviders))
+ []
+ (let [providers (vec (Security/getProviders))
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))))
-(defn- create-fns []
+(defn create-fn!
+ [algorithm-name]
+ (let [update-meta (fn [meta]
+ (assoc meta
+ :doc (str "Encode the given message with the " algorithm-name " algorithm.")
+ :arglists '([message])))]
+ (-> (intern 'digest
+ (symbol (lower-case algorithm-name))
+ (partial digest algorithm-name))
+ (alter-meta! update-meta))))
+
+(defn- create-fns
"Create utility function for each digest algorithms.
For example will create an md5 function for MD5 algorithm."
- (dorun (map #(intern 'digest (symbol (lower-case %)) (partial digest %))
- (algorithms))))
+ []
+ (doseq [algorithm (algorithms)]
+ (create-fn! algorithm)))
-; Create utililty functions such as md5, sha-2 ...
+; Create utility functions such as md5, sha-256 ...
(create-fns)
=====================================
test/clojure.png deleted
=====================================
Binary files a/test/clojure.png and /dev/null differ
=====================================
test/digest_test.clj
=====================================
@@ -1,27 +1,33 @@
(ns digest-test
- (:use [digest] :reload-all)
- (:use [clojure.string :only (lower-case)])
- (:use [clojure.test])
+ (:require [clojure.string :refer [lower-case includes?]]
+ [clojure.test :refer :all]
+ [digest :refer :all])
(:import java.io.File))
(deftest md5-test
(is (= (digest "md5" "foo") "acbd18db4cc2f85cedef654fccc4a4d8")))
(deftest sha-256-test
- (is (= (sha-256 "foo")
+ (is (= (sha-256 "foo")
"2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae")))
(deftest algorithms-test
(let [names (algorithms)]
- (is not (empty? names))
+ (is (not (empty? names)))
(is (names "SHA-1"))))
(deftest utils-test
(for [name (algorithms)]
(dorun (is (ns-resolve *ns* (symbol (lower-case name)))))))
+(deftest function-metadata-test
+ (is (includes? (:doc (meta #'sha-256))
+ "SHA-256"))
+ (is (= '([message])
+ (:arglists (meta #'md5)))))
+
(def ^:dynamic *logo-md5* "38cf20fa3c9dc72be56965eb1c311dfa")
-(def ^:dynamic *logo-sha256*
+(def ^:dynamic *logo-sha256*
"42c2af2a0509832f39d0cef3ecd1612b7857c55abbe2170470eabb2a0318701c")
(deftest file-test
@@ -34,5 +40,5 @@
(md5 nil))
(deftest length-test
- (is (= (sha (File. "test/length.txt"))
- "007b65165b253172d054189e8e3175f3bcb9e28e")))
+ (is (= (sha (File. "test/length.txt"))
+ "007b65165b253172d054189e8e3175f3bcb9e28e")))
View it on GitLab: https://salsa.debian.org/clojure-team/clj-digest-clojure/-/commit/2f0419b20b4878f959d6a19913960b72add896b5
--
View it on GitLab: https://salsa.debian.org/clojure-team/clj-digest-clojure/-/commit/2f0419b20b4878f959d6a19913960b72add896b5
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20201217/2de631e1/attachment.html>
More information about the pkg-java-commits
mailing list