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
+1 for Pandect. It's an excellent library which leverages bouncy castle and
has had tons of top notch work put into it. Fast, well documented, and super
easy to use.
--
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email
(- Hello, World! .getBytes create-hash ...)
Will get you the hash of the string encoded to bytes using *some random
encoding*. (Whatever the platform you're currently running on defaults to.)
You should explicitly choose an encoding and stick to it. I'd suggest UTF-8
since that can encode all
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
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:
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])
You can use java.security.MessageDigest. For example:
(defn create-hash
[data-barray]
(.digest (java.security.MessageDigest/getInstance SHA1) data-barray))
It takes and returns a byte array, but converting from/to a string is
fairly straight-forward:
(- Hello, World!
.getBytes