aboutsummaryrefslogtreecommitdiffstats
path: root/lib/concepts/Hash.mli
blob: 256f3cd69073034777c1a5589845eb4cc6a4b231 (plain) (blame)
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
(** an abstract value representing a hash *)
type hash

(** the size of a hash, in bytes *)
val size : int

(** given a bag of bytes, compute its hash *)
val hash_of_bytes : bytes -> hash

(** given a blob, compute its hash *)
val hash_of_blob : Blob.t -> hash

(** given an int, compute its hash *)
val hash_of_int : int -> hash

(** given a hash, return a representation of it as a string (/not/ the usual hex representation!) *)
val to_raw_string : hash -> string

(** given a string containing a representation of a hash (as per `to_raw_string`), return the corresponding hash *)
val of_raw_string : string -> hash

(** given a hash, return a representation of it as a string suitable for being displayed to humans *)
val to_hum_string : hash -> string

(** compare two hashes lexicographically *)
val compare : hash -> hash -> Utilities.Ordering.t

(** given two hashes, are they the same? *)
val hash_equals : hash -> hash -> bool

(** given a hash, return a `bytes` representation of it *)
val bytes_of_hash : hash -> bytes

(** given a hash, return a `blob` representation of it *)
val blob_of_hash : hash -> Blob.t

(** pick one every 1/2^n hashes *)
val pick : int -> hash -> bool