I have a 100% Racket impl of hmac-sha1 here. Good enough for signing smaller sized data such as API calls: <br><br><a href="https://github.com/RayRacine/racketlib/blob/master/crypto/hmac.rkt">https://github.com/RayRacine/racketlib/blob/master/crypto/hmac.rkt</a><br>
<br><br><div class="gmail_quote">On Mon, May 14, 2012 at 5:27 AM, Shawn Smith <span dir="ltr"><<a href="mailto:shawn.p.smith@gmail.com" target="_blank">shawn.p.smith@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Norman,<div><br></div><div>Thanks, that looks great. I'll give it a shot.</div><span class="HOEnZb"><font color="#888888"><div><br></div></font></span><div><span class="HOEnZb"><font color="#888888">Shawn</font></span><div>
<div class="h5"><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><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><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><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></div></div>
<br>____________________<br>
Racket Users list:<br>
<a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
<br></blockquote></div><br>