File tree 2 files changed +5
-2
lines changed
2 files changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,7 @@ let char_hex n =
50
50
Char. unsafe_chr (n + if n < 10 then Char. code '0' else (Char. code 'a' - 10 ))
51
51
52
52
let to_hex d =
53
+ if String. length d <> 16 then invalid_arg " Digest.to_hex" ;
53
54
let result = Bytes. create 32 in
54
55
for i = 0 to 15 do
55
56
let x = Char. code d.[i] in
@@ -59,7 +60,7 @@ let to_hex d =
59
60
Bytes. unsafe_to_string result
60
61
61
62
let from_hex s =
62
- if String. length s <> 32 then raise ( Invalid_argument " Digest.from_hex" ) ;
63
+ if String. length s <> 32 then invalid_arg " Digest.from_hex" ;
63
64
let digit c =
64
65
match c with
65
66
| '0' ..'9' -> Char. code c - Char. code '0'
Original file line number Diff line number Diff line change @@ -73,7 +73,9 @@ val input : in_channel -> t
73
73
(* * Read a digest from the given input channel. *)
74
74
75
75
val to_hex : t -> string
76
- (* * Return the printable hexadecimal representation of the given digest. *)
76
+ (* * Return the printable hexadecimal representation of the given digest.
77
+ Raise [Invalid_argument] if the argument is not exactly 16 bytes.
78
+ *)
77
79
78
80
val from_hex : string -> t
79
81
(* * Convert a hexadecimal representation back into the corresponding digest.
You can’t perform that action at this time.
0 commit comments