moonpool/dev/ocaml/Stdlib/Digest/index.html
2023-08-28 17:11:38 +00:00

2 lines
No EOL
8 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Digest (ocaml.Stdlib.Digest)</title><link rel="stylesheet" href="../../../_odoc-theme/odoc.css"/><meta charset="utf-8"/><meta name="generator" content="odoc 2.2.1"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><script src="../../../highlight.pack.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body class="odoc"><nav class="odoc-nav"><a href="../index.html">Up</a> <a href="../../index.html">ocaml</a> &#x00BB; <a href="../index.html">Stdlib</a> &#x00BB; Digest</nav><header class="odoc-preamble"><h1>Module <code><span>Stdlib.Digest</span></code></h1><p>MD5 message digest.</p><p>This module provides functions to compute 128-bit 'digests' of arbitrary-length strings or files. The algorithm used is MD5.</p><p>The MD5 hash function is not cryptographically secure. Hence, this module should not be used for security-sensitive applications. More recent, stronger cryptographic primitives should be used instead.</p></header><div class="odoc-content"><div class="odoc-spec"><div class="spec type anchored" id="type-t"><a href="#type-t" class="anchor"></a><code><span><span class="keyword">type</span> t</span><span> = string</span></code></div><div class="spec-doc"><p>The type of digests: 16-character strings.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-compare"><a href="#val-compare" class="anchor"></a><code><span><span class="keyword">val</span> compare : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> int</span></code></div><div class="spec-doc"><p>The comparison function for 16-character digest, with the same specification as <a href="../index.html#val-compare"><code>Stdlib.compare</code></a> and the implementation shared with <a href="../String/index.html#val-compare"><code>String.compare</code></a>. Along with the type <code>t</code>, this function <code>compare</code> allows the module <code>Digest</code> to be passed as argument to the functors <a href="../Set/Make/index.html"><code>Set.Make</code></a> and <a href="../Map/Make/index.html"><code>Map.Make</code></a>.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.00.0</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-equal"><a href="#val-equal" class="anchor"></a><code><span><span class="keyword">val</span> equal : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> bool</span></code></div><div class="spec-doc"><p>The equal function for 16-character digest.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.03.0</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-string"><a href="#val-string" class="anchor"></a><code><span><span class="keyword">val</span> string : <span>string <span class="arrow">&#45;&gt;</span></span> <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p>Return the digest of the given string.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-bytes"><a href="#val-bytes" class="anchor"></a><code><span><span class="keyword">val</span> bytes : <span>bytes <span class="arrow">&#45;&gt;</span></span> <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p>Return the digest of the given byte sequence.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.02.0</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-substring"><a href="#val-substring" class="anchor"></a><code><span><span class="keyword">val</span> substring : <span>string <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p><code>Digest.substring s ofs len</code> returns the digest of the substring of <code>s</code> starting at index <code>ofs</code> and containing <code>len</code> characters.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-subbytes"><a href="#val-subbytes" class="anchor"></a><code><span><span class="keyword">val</span> subbytes : <span>bytes <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p><code>Digest.subbytes s ofs len</code> returns the digest of the subsequence of <code>s</code> starting at index <code>ofs</code> and containing <code>len</code> bytes.</p><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.02.0</li></ul></div></div><div class="odoc-spec"><div class="spec value external anchored" id="val-channel"><a href="#val-channel" class="anchor"></a><code><span><span class="keyword">val</span> channel : <span><a href="../index.html#type-in_channel">in_channel</a> <span class="arrow">&#45;&gt;</span></span> <span>int <span class="arrow">&#45;&gt;</span></span> <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p>If <code>len</code> is nonnegative, <code>Digest.channel ic len</code> reads <code>len</code> characters from channel <code>ic</code> and returns their digest, or raises <code>End_of_file</code> if end-of-file is reached before <code>len</code> characters are read. If <code>len</code> is negative, <code>Digest.channel ic len</code> reads all characters from <code>ic</code> until end-of-file is reached and return their digest.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-file"><a href="#val-file" class="anchor"></a><code><span><span class="keyword">val</span> file : <span>string <span class="arrow">&#45;&gt;</span></span> <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p>Return the digest of the file whose name is given.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-output"><a href="#val-output" class="anchor"></a><code><span><span class="keyword">val</span> output : <span><a href="../index.html#type-out_channel">out_channel</a> <span class="arrow">&#45;&gt;</span></span> <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> unit</span></code></div><div class="spec-doc"><p>Write a digest on the given output channel.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-input"><a href="#val-input" class="anchor"></a><code><span><span class="keyword">val</span> input : <span><a href="../index.html#type-in_channel">in_channel</a> <span class="arrow">&#45;&gt;</span></span> <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p>Read a digest from the given input channel.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-to_hex"><a href="#val-to_hex" class="anchor"></a><code><span><span class="keyword">val</span> to_hex : <span><a href="#type-t">t</a> <span class="arrow">&#45;&gt;</span></span> string</span></code></div><div class="spec-doc"><p>Return the printable hexadecimal representation of the given digest.</p><ul class="at-tags"><li class="raises"><span class="at-tag">raises</span> <span class="value">Invalid_argument</span> <p>if the argument is not exactly 16 bytes.</p></li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-from_hex"><a href="#val-from_hex" class="anchor"></a><code><span><span class="keyword">val</span> from_hex : <span>string <span class="arrow">&#45;&gt;</span></span> <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p>Convert a hexadecimal representation back into the corresponding digest.</p><ul class="at-tags"><li class="raises"><span class="at-tag">raises</span> <span class="value">Invalid_argument</span> <p>if the argument is not exactly 32 hexadecimal characters.</p></li></ul><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 4.00.0</li></ul></div></div></div></body></html>