[plt-scheme] FFI and MD5

From: Jens Axel Søgaard (jensaxel at soegaard.net)
Date: Wed Jan 31 16:35:35 EST 2007

Woodhouse, Gregory J. skrev:
> Well, that's a Unicode string, and if it is encoded as UTF-8, then it's not surprising that the likes of 1d are encoded a single bytes, but higher valued codepoints are encoded as multiple bytes. Just a guess.  

For a second, I thought, you had the solution, but ...

If I use list->bytes instead of integer->string, then I get:

   (define (md5 d)
     (let ([md (MD5 d #f)])
       (let loop ([i 0] [cs '()])
         (if (= i 16)
             (list->bytes (reverse cs))
             (loop (+ i 1) (cons (ptr-ref md _byte i) cs))))))

I get:

   > (md5 #"")

and I was expecting:


Jens Axel Søgaard

Posted on the users mailing list.