From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id AAA04535; Fri, 4 May 2001 00:32:38 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id AAA04601 for ; Fri, 4 May 2001 00:32:37 +0200 (MET DST) Received: from www.invert.com (invert.com [209.164.21.15]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id f43MWZH27593 for ; Fri, 4 May 2001 00:32:35 +0200 (MET DST) Received: (from miles@localhost) by www.invert.com (8.10.1/8.10.1AA) id f43MWYb28348 for caml-list@inria.fr; Thu, 3 May 2001 15:32:34 -0700 (PDT) (envelope-from miles) Date: Thu, 3 May 2001 15:32:34 -0700 From: Miles Egan To: caml-list@inria.fr Subject: [Caml-list] printable digest strings Message-ID: <20010503153234.A28259@caddr.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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