I found that the hexadecimal returned by Zach's solution sometimes has a "-" prefix (for example, for the "hello" string). I guess because BigInteger(byte[]) (http://docs.oracle.com/javase/8/docs/api/java/math/BigInteger.html#BigInteger-byte:A-) interprets the byte array as a two's-complement binary number, so it may be negative (http://en.wikipedia.org/wiki/Two's_complement).
To always get a SHA1 without the dash/minus prefix, BigInteger(int signum, byte[] magnitude) (http://docs.oracle.com/javase/8/docs/api/java/math/BigInteger.html#BigInteger-int-byte:A-) can be used, like this: (->> (.getBytes "hello" "UTF-8") (.digest (java.security.MessageDigest/getInstance "SHA1")) (java.math.BigInteger. 1) (format "%x")) On Sunday, March 2, 2014 5:04:48 PM UTC+1, action wrote: > > ok,think you! > > 在 2014年3月2日星期日UTC+8上午12时28分25秒,JPH写道: >> >> I've had good experiences with https://github.com/xsc/pandect. >> >> You can also use Java interop like this: >> https://gist.github.com/prasincs/827272 >> >> JPH >> >> >> On 03/02/2014 12:26 AM, action wrote: >> > do like this: >> > (ns clojurewerkz.support.hashing >> > (:require [clojurewerkz.support.internal :as i]) >> > (:import [com.google.common.hash Hashing HashFunction HashCode])) >> > but: >> > FileNotFoundException Could not locate clojurewerkz/support__init.class >> or >> > cloju >> > rewerkz/support.clj on classpath: clojure.lang.RT.load (RT.java:443) >> > how to set the dependencies, or other solution? >> > >> > Think you >> > >> > >> >> -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.