[gnutls-devel] Guile-GnuTLS | Missing zeros in digest/sha* output (#18)

Read-only notification of GnuTLS library development activities gnutls-devel at lists.gnutls.org
Tue Aug 22 09:51:12 CEST 2023




Vivien Kraus Would Rather Not Be On Gitlab_com commented: https://gitlab.com/gnutls/guile/-/issues/18#note_1522341505

Hello! This is just an issue with the format strings: it removes leading zeros for each individual byte.

The Guile manual for format has a few examples with the format options, and I think this format is what you want, to have 2-character hex numbers padded with 0:

```scheme
(use-modules (rnrs bytevectors) (srfi srfi-26))

(string-join
   (map (cut format #f "~2,'0x" <>)
        (bytevector->u8-list (hash-direct digest/sha256
                                          (string->utf8 "test"))))
   "")
```

I get `"9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"`

-- 
Reply to this email directly or view it on GitLab: https://gitlab.com/gnutls/guile/-/issues/18#note_1522341505
You're receiving this email because of your account on gitlab.com.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gnupg.org/pipermail/gnutls-devel/attachments/20230822/388753b8/attachment.html>


More information about the Gnutls-devel mailing list