On Monday, March 4, 2013 10:54:13 PM UTC+4, larry google groups wrote:
>
> Right now I am using this block of code: 
>
> (let [username (get-in @um/interactions [:omniture-api- 
> credentials :username]) 
>   secret (get-in @um/interactions [:omniture-api-credentials :shared- 
> secret]) 
>   random-number (math/round (* (rand 1 ) 1000000)) 
>   nonce (DigestUtils/md5Hex (str random-number)) 
>   nonce-encoded-base64 (Base64/encodeBase64String (.getBytes nonce)) 
>   date-formatter (new SimpleDateFormat "yyyy-MM-dd'T'HH:mm:ss") 
>   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)) 
>   digest-base64 (Base64/encodeBase64String digest) 
>   header (apply str " UsernameToken Username=\""  username  "\" 
> PasswordDigest=\"" digest-base64 "\" Nonce=\"" nonce-encoded-base64 
> "\" Created=\"" created "\"")] 
> header) 
>
> And I get output that contains an equal sign, which I think is 
> suspect: 
>
> PasswordDigest="r+HWjSAk8AUvo/QmKKfbqQFnJ18=" 
> Nonce="NmQxNGUwZjVlMjFhYjE1MzQ4MjUxYTA1MTg1YzE3ZTg=" 
>
> The developer at Omniture reminded me of the characters allowed into 
> Base64: 
>
> "  You can tell a given string is base64 encoded because it can only 
> have 64 specific characters in the string: 
> A-Z 
> a-z 
> 0-9 
> + 
> / 
> That's 26 + 26 + 10 + 2 = 64 
> http://en.wikipedia.org/wiki/Base64    " 
>
>
> I assume that means that if I see a "=" in the string, then it is not 
> really Base64 encoded? 
>
>
> It is. See  http://en.wikipedia.org/wiki/Base64 , the "Padding" section.

>
>
>
>
>
>
>
> On Mar 4, 1:43 pm, Craig Brozefsky <cr...@red-bean.com> wrote: 
> > Craig Brozefsky <cr...@red-bean.com> writes: 
> > 
> > .. 
> > 
> > Sorry, didn't reaze you wanted the output to be base64 encoded, in which 
> > case, add these funcs: 
> > 
> > (defn base64-encode [^bytes v] 
> >   (javax.xml.bind.DatatypeConverter/printBase64Binary v)) 
> > 
> > (defn sha1-base64 [^String v] 
> >       (-> (.getBytes v) 
> >           (sha1) 
> >           (base64-encode))) 
> > 
> > -- 
> > Craig Brozefsky <cr...@red-bean.com> 
> > Premature reification is the root of all evil 
>

-- 
-- 
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