From: Miles Egan <miles@caddr.com>
To: caml-list@inria.fr
Subject: [Caml-list] printable digest strings
Date: Thu, 3 May 2001 15:32:34 -0700 [thread overview]
Message-ID: <20010503153234.A28259@caddr.com> (raw)
I can't seem to find a function to create printable versions of the digest
strings generated by the digest module, like the output of the common unix
md5sum utility. Am I missing something or does it not exist? If not, it might
be a handy addition to the Digest module. At the moment I'm using this fairly
gross code of my own:
let hexchar nibble =
let ac = Char.code 'a' in
let zc = Char.code '0' in
if nibble > 9 then
Char.chr (nibble + ac - 10)
else
Char.chr (nibble + zc)
let hexstring s =
let
j = ref 0 and
h = String.create (String.length s * 2) in
for i = 0 to (String.length s - 1) do
let
high = ((Char.code s.[i]) lsr 4) land 0xf and
low = (Char.code s.[i]) land 0xf in
let _ = h.[!j] <- hexchar high in
let _ = j := !j + 1 in
let _ = h.[!j] <- hexchar low in
j := !j + 1
done;
h
--
miles
-------------------
To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr
next reply other threads:[~2001-05-03 22:32 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-05-03 22:32 Miles Egan [this message]
2001-05-04 9:15 ` Hendrik Tews
2001-05-04 9:37 ` Xavier Leroy
2001-05-04 14:00 ` Miles Egan
2001-05-04 14:50 ` Brian Rogoff
2001-05-04 20:27 ` Chris Hecker
2001-05-04 22:54 ` Miles Egan
2001-05-06 18:56 ` [Caml-list] Wserver: Values of global variables lost Mattias Waldau
2001-05-07 8:58 ` Daniel de Rauglaudre
2001-05-07 17:00 ` Mattias Waldau
2001-05-07 18:16 ` Daniel de Rauglaudre
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20010503153234.A28259@caddr.com \
--to=miles@caddr.com \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox