summaryrefslogtreecommitdiff
path: root/devdocs/go/hash%2Fcrc64%2Findex.html
blob: 2a4d782ace0fd5477be3903c97088900f56e8a15 (plain)
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
<h1> Package crc64  </h1>     <ul id="short-nav">
<li><code>import "hash/crc64"</code></li>
<li><a href="#pkg-overview" class="overviewLink">Overview</a></li>
<li><a href="#pkg-index" class="indexLink">Index</a></li>
</ul>     <h2 id="pkg-overview">Overview </h2> <p>Package crc64 implements the 64-bit cyclic redundancy check, or CRC-64, checksum. See <a href="https://en.wikipedia.org/wiki/Cyclic_redundancy_check">https://en.wikipedia.org/wiki/Cyclic_redundancy_check</a> for information. </p>     <h2 id="pkg-index">Index </h2>  <ul id="manual-nav">
<li><a href="#pkg-constants">Constants</a></li>
<li><a href="#Checksum">func Checksum(data []byte, tab *Table) uint64</a></li>
<li><a href="#New">func New(tab *Table) hash.Hash64</a></li>
<li><a href="#Update">func Update(crc uint64, tab *Table, p []byte) uint64</a></li>
<li><a href="#Table">type Table</a></li>
<li> <a href="#MakeTable">func MakeTable(poly uint64) *Table</a>
</li>
</ul> <h3>Package files</h3> <p>  <span>crc64.go</span>  </p>   <h2 id="pkg-constants">Constants</h2> <p>Predefined polynomials. </p>
<pre data-language="go">const (
    // The ISO polynomial, defined in ISO 3309 and used in HDLC.
    ISO = 0xD800000000000000

    // The ECMA polynomial, defined in ECMA 182.
    ECMA = 0xC96C5795D7870F42
)</pre> <p>The size of a CRC-64 checksum in bytes. </p>
<pre data-language="go">const Size = 8</pre> <h2 id="Checksum">func <span>Checksum</span>  </h2> <pre data-language="go">func Checksum(data []byte, tab *Table) uint64</pre> <p>Checksum returns the CRC-64 checksum of data using the polynomial represented by the <a href="#Table">Table</a>. </p>
<h2 id="New">func <span>New</span>  </h2> <pre data-language="go">func New(tab *Table) hash.Hash64</pre> <p>New creates a new hash.Hash64 computing the CRC-64 checksum using the polynomial represented by the <a href="#Table">Table</a>. Its Sum method will lay the value out in big-endian byte order. The returned Hash64 also implements <span>encoding.BinaryMarshaler</span> and <span>encoding.BinaryUnmarshaler</span> to marshal and unmarshal the internal state of the hash. </p>
<h2 id="Update">func <span>Update</span>  </h2> <pre data-language="go">func Update(crc uint64, tab *Table, p []byte) uint64</pre> <p>Update returns the result of adding the bytes in p to the crc. </p>
<h2 id="Table">type <span>Table</span>  </h2> <p>Table is a 256-word table representing the polynomial for efficient processing. </p>
<pre data-language="go">type Table [256]uint64</pre> <h3 id="MakeTable">func <span>MakeTable</span>  </h3> <pre data-language="go">func MakeTable(poly uint64) *Table</pre> <p>MakeTable returns a <a href="#Table">Table</a> constructed from the specified polynomial. The contents of this <a href="#Table">Table</a> must not be modified. </p><div class="_attribution">
  <p class="_attribution-p">
    &copy; Google, Inc.<br>Licensed under the Creative Commons Attribution License 3.0.<br>
    <a href="http://golang.org/pkg/hash/crc64/" class="_attribution-link">http://golang.org/pkg/hash/crc64/</a>
  </p>
</div>