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