module type S =sig
..end
此為雜湊函數的簽名,此函數會從字串、位元組陣列和檔案產生長度為 hash_length
的摘要。
typet =
string
摘要的類型。
val hash_length : int
摘要的長度,以位元組為單位。
val compare : t -> t -> int
比較兩個摘要,規格與 compare
相同。
val equal : t -> t -> bool
測試兩個摘要是否相等。
val string : string -> t
傳回給定字串的摘要。
val bytes : bytes -> t
傳回給定位元組序列的摘要。
val substring : string -> int -> int -> t
substring s ofs len
傳回字串 s
從索引 ofs
開始,包含 len
個字元的子字串的摘要。
val subbytes : bytes -> int -> int -> t
subbytes s ofs len
傳回位元組序列 s
從索引 ofs
開始,包含 len
個位元組的子序列的摘要。
val channel : in_channel -> int -> t
從通道讀取字元並傳回其摘要。請參閱 Digest.channel
以取得完整規格。
val file : string -> t
傳回給定名稱檔案的摘要。
val output : out_channel -> t -> unit
在給定的輸出通道上寫入摘要。
val input : in_channel -> t
從給定的輸入通道讀取摘要。
val to_hex : t -> string
傳回給定摘要的可列印十六進位表示法。
Invalid_argument
如果參數的長度不是 hash_length
,val of_hex : string -> t
將十六進位表示法轉換回對應的摘要。
Invalid_argument
如果參數的長度不是 2 * hash_length
,或者如果參數包含非十六進位字元。