Skip to content

Missing zeros in digest/sha* output

Hi!

I wrote a simple sha256sum procedure:

(define (digest-sha256 str)
  (string-join
   (map (cut format #f "~x" <>)
        (bytevector->u8-list (hash-direct digest/sha256
                                          (string->utf8 str))))
   ""))

But:

(digest-sha256 "test")
9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2bb822cd15d6c15b0f0a8
# echo -n test | sha256sum -
9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08

It seems there should be a 0 between f0 and a at the end. Is this a bug or am I doing something wrong?