> expects its argument to be a byte 
> array:http://docs.oracle.com/javase/6/docs/api/java/security/MessageDigest....
>
> which can be obtained from a string using String#getBytes.


I appreciate your suggestion. For most of the attempts that I have
made, I have used this code:

 nonce (DigestUtils/md5Hex (random-string 32))
 nonce-encoded-base64 (Base64/encodeBase64 (.getBytes nonce))
 date-formatter (new SimpleDateFormat "yyyy-MM-dd'T'HH:mm:ss'Z'")
 created (.format date-formatter (new Date))
 digest-as-string (apply str nonce created secret)
 digest (.digest (java.security.MessageDigest/getInstance "sha1")
(.getBytes digest-as-string))

So the SHA1 is given a Byte array. This fails to give me a correctly
formatted digest.





On Mar 4, 11:04 am, Michael Klishin <michael.s.klis...@gmail.com>
wrote:
> 2013/3/4 larry google groups <lawrencecloj...@gmail.com>
>
> > I appreciate your suggestion, but I feel that I need to understand why
> > I failed when I used these classes:
>
> (.digest (java.security.MessageDigest/getInstance "sha1")
> digest-as-string)
>
> expects its argument to be a byte 
> array:http://docs.oracle.com/javase/6/docs/api/java/security/MessageDigest....
>
> which can be obtained from a string using String#getBytes.
>
> Also, in
>
> (apply str (.getBytes nonce) created secret)
>
> I am not sure you get what you expect. clojure.core/str will take a string
> representation of a byte array and concat it. What you probably want is
> to concat all strings and then .getBytes from the result. Compare:
>
> user=> (str (.getBytes "aa") "bb" "cc")
> "[B@5d5d0293bbcc"
> user=> (str "aa" "bb" "cc")
> "aabbcc"
> user=> (.getBytes (str "aa" "bb" "cc"))
> #<byte[] [B@d9f8120>
> --
> MK
>
> http://github.com/michaelklishinhttp://twitter.com/michaelklishin

-- 
-- 
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/groups/opt_out.


Reply via email to