Hi Norman,<div><br></div><div>Thanks, that looks great. I'll give it a shot.</div><div><br></div><div>Shawn<br><div><br><div class="gmail_quote">On Mon, May 14, 2012 at 2:23 AM, Norman Gray <span dir="ltr"><<a href="mailto:norman@astro.gla.ac.uk" target="_blank">norman@astro.gla.ac.uk</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
Shawn, hello.<br>
<div class="im"><br>
On 2012 May 14, at 09:12, Shawn Smith wrote:<br>
<br>
> I guess I've tracked the problem down to the fact that the Racket hash is<br>
> not a digest.<br>
<br>
</div>I think it is, but the problem is that you're not displaying the resulting byte string correctly.<br>
<div class="im"><br>
> echo -n "foo" | openssl dgst -sha1 -hmac "privatekey"<br>
><br>
> I get what I'm looking for, a 40 character hex hash:<br>
><br>
> 6d1198d3c8770f2409c6b73ed11af9d2076e4588<br>
><br>
> I'm not sure how to get Racket to do this as well. Does anyone know?<br>
<br>
</div>(require web-server/stuffers/hmac-sha1<br>
file/sha1) ; or openssl/sha1<br>
<br>
(bytes->hex-string (HMAC-SHA1 #"privatekey" #"foo"))<br>
<br>
=> "6d1198d3c8770f2409c6b73ed11af9d2076e4588"<br>
<br>
HMAC-SHA1 produces the result as a byte string (which is different from a string). Base-64 encoding writes out that string of bytes in a form which can be safely mailed -- that's not what you want.<br>
<br>
Instead, bytes->hex-string formats each byte in the string as a two-digit hex number, resulting in a string.<br>
<br>
All the best,<br>
<br>
Norman<br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
--<br>
Norman Gray : <a href="http://nxg.me.uk" target="_blank">http://nxg.me.uk</a><br>
SUPA School of Physics and Astronomy, University of Glasgow, UK<br>
<br>
</font></span></blockquote></div><br></div></div>