-
Notifications
You must be signed in to change notification settings - Fork 373
/
Copy pathopamHash.mli
52 lines (37 loc) · 1.75 KB
/
opamHash.mli
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
(**************************************************************************)
(* *)
(* Copyright 2016-2017 OCamlPro *)
(* *)
(* All rights reserved. This file is distributed under the terms of the *)
(* GNU Lesser General Public License version 2.1, with the special *)
(* exception on linking described in the file LICENSE. *)
(* *)
(**************************************************************************)
(** Stored as hexadecimal strings *)
type kind = [ `MD5 | `SHA256 | `SHA512 ]
type t
val kind: t -> kind
(** The value of the hash, as a string of hexadecimal characters *)
val contents: t -> string
val string_of_kind: kind -> string
val md5: string -> t
val sha256: string -> t
val sha512: string -> t
include OpamStd.ABSTRACT with type t := t
val of_string_opt: string -> t option
val compare_kind: kind -> kind -> int
(** Check if [hash] contains only 0 *)
val is_null: t -> bool
(** returns a sub-path specific to this hash, e.g.
"md5/d4/d41d8cd98f00b204e9800998ecf8427e", as a list *)
val to_path: t -> string list
(** Sorts the list from best hash (SHA512, ...) to weakest (..., MD5) *)
val sort : t list -> t list
val check_file: string -> t -> bool
(** Like {!check_file}, but returns the actual mismatching hash of the file, or
[None] in case of match *)
val mismatch: string -> t -> t option
(** Compute hash of the given file *)
val compute: ?kind:kind -> string -> t
(** Compute the hash of the given string *)
val compute_from_string: ?kind:kind -> string -> t