why can't I call .update on a MessageDigest instance
when i run this from the repl:
(def md (MessageDigest/开发者_Python百科getInstance "SHA-1"))
(. md update (into-array [(byte 1) (byte 2) (byte 3)]))
I get:
No matching method found: update for class java.security.MessageDigest$Delegate
the Java 6 docs for MessageDigest show:
update(byte[] input)
Updates the digest using the specified array of bytes.
and the class of (class (into-array [(byte 1) (byte 2) (byte 3)]))
is
[Ljava.lang.Byte;
Am I missing something in the definition of update?
Not creating the class I think I am? Not passing it the type I think I am?Because you are calling update(Byte[]) which is not defined in MessageDigest. You need to convert it into primitive array.
You can do something like this,
(defn updateBytes [#^MessageDigest md, #^bytes data]
(.update md data))
Try:
(. md update (into-array Byte/TYPE [(byte 1) (byte 2) (byte 3)]))
精彩评论