summaryrefslogtreecommitdiffstats
path: root/stdlib
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/digest.ml10
-rw-r--r--stdlib/digest.mli10
-rw-r--r--stdlib/sys.ml2
3 files changed, 18 insertions, 4 deletions
diff --git a/stdlib/digest.ml b/stdlib/digest.ml
index 15755c31a..29d1295c7 100644
--- a/stdlib/digest.ml
+++ b/stdlib/digest.ml
@@ -30,7 +30,7 @@ let substring str ofs len =
let file filename =
let ic = open_in_bin filename in
- let d = channel ic (in_channel_length ic) in
+ let d = channel ic (-1) in
close_in ic;
d
@@ -41,3 +41,11 @@ let input chan =
let digest = String.create 16 in
really_input chan digest 0 16;
digest
+
+let to_hex d =
+ let result = String.create 32 in
+ for i = 0 to 15 do
+ String.blit (Printf.sprintf "%02x" (int_of_char d.[i])) 0 result (2*i) 2;
+ done;
+ result
+;;
diff --git a/stdlib/digest.mli b/stdlib/digest.mli
index bbcf51604..342a3a4ea 100644
--- a/stdlib/digest.mli
+++ b/stdlib/digest.mli
@@ -33,8 +33,12 @@ val substring : string -> int -> int -> t
characters. *)
external channel : in_channel -> int -> t = "md5_chan"
-(** [Digest.channel ic len] reads [len] characters from channel [ic]
- and returns their digest. *)
+(** If [len] is nonnegative, [Digest.channel ic len] reads [len]
+ characters from channel [ic] and returns their digest, or raises
+ [End_of_file] if end-of-file is reached before [len] characters
+ are read. If [len] is negative, [Digest.channel ic len] reads
+ characters from [ic] until end-of-file is reached and return their
+ digest. *)
val file : string -> t
(** Return the digest of the file whose name is given. *)
@@ -45,3 +49,5 @@ val output : out_channel -> t -> unit
val input : in_channel -> t
(** Read a digest from the given input channel. *)
+val to_hex : t -> string
+(** Return the printable hexadecimal representation of the given digest. *)
diff --git a/stdlib/sys.ml b/stdlib/sys.ml
index 9da1b6c48..3a096399a 100644
--- a/stdlib/sys.ml
+++ b/stdlib/sys.ml
@@ -78,4 +78,4 @@ let catch_break on =
(* OCaml version numbers and strings, moved from utils/config.mlp.
Must be in the format described in sys.mli. *)
-let ocaml_version = "3.04+6 (2002-02-05)"
+let ocaml_version = "3.04+7 (2002-02-25)"