[racket] Cookie Indigestion
J G Cho wrote at 05/18/2011 04:23 AM:
> (define (make-digest s1 s2)
> (bytes->string/utf-8
> (base64-encode
> (HMAC-SHA1 (string->bytes/utf-8 s1)
> (string->bytes/utf-8 s2)))))
>
> I then use it to make a cookie like:
>
> (define digest
> (make-digest "saltycracker" (string-append "time" time "id" "joseph")))
>
> (define digest-cookie
> (make-cookie "digest" digest))
>
> Writing it out seems to go okay but when I try to read it back, I am
> greeted with:
>
> lexer: No match found in input starting with: "WFs1fa0jLTOXqiLG08EtBq1wNYI=
>
Is the problem that the BASE64 output contains "=" and newline
characters, and that's getting into the HTTP header verbatim?
If that's the problem, then probably you want to trim the "=" and
newline characters from the string. (You could re-encode, but that
would be redundant, since the purpose of BASE64 is to encode bytes
safely for transport.)
--
http://www.neilvandyke.org/