diff options
| author | Craig Jennings <c@cjennings.net> | 2025-08-14 22:58:58 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2025-08-14 22:58:58 -0500 |
| commit | 82ba818ff456bcd6d56a06226e3f27e98fbb55c3 (patch) | |
| tree | 158cfc17b2f644a10f063cb546752cfaae12c97f /devdocs/go/hash%2Fcrc32%2Findex.html | |
| parent | 9278ddd4ea1a8b1a4c1edaa8894516e3f48d245b (diff) | |
| download | dotemacs-82ba818ff456bcd6d56a06226e3f27e98fbb55c3.tar.gz dotemacs-82ba818ff456bcd6d56a06226e3f27e98fbb55c3.zip | |
removing all downloaded devdocs files
Diffstat (limited to 'devdocs/go/hash%2Fcrc32%2Findex.html')
| -rw-r--r-- | devdocs/go/hash%2Fcrc32%2Findex.html | 62 |
1 files changed, 0 insertions, 62 deletions
diff --git a/devdocs/go/hash%2Fcrc32%2Findex.html b/devdocs/go/hash%2Fcrc32%2Findex.html deleted file mode 100644 index 65aed1328..000000000 --- a/devdocs/go/hash%2Fcrc32%2Findex.html +++ /dev/null @@ -1,62 +0,0 @@ -<h1> Package crc32 </h1> <ul id="short-nav"> -<li><code>import "hash/crc32"</code></li> -<li><a href="#pkg-overview" class="overviewLink">Overview</a></li> -<li><a href="#pkg-index" class="indexLink">Index</a></li> -<li><a href="#pkg-examples" class="examplesLink">Examples</a></li> -</ul> <h2 id="pkg-overview">Overview </h2> <p>Package crc32 implements the 32-bit cyclic redundancy check, or CRC-32, checksum. See <a href="https://en.wikipedia.org/wiki/Cyclic_redundancy_check">https://en.wikipedia.org/wiki/Cyclic_redundancy_check</a> for information. </p> -<p>Polynomials are represented in LSB-first form also known as reversed representation. </p> -<p>See <a href="https://en.wikipedia.org/wiki/Mathematics_of_cyclic_redundancy_checks#Reversed_representations_and_reciprocal_polynomials">https://en.wikipedia.org/wiki/Mathematics_of_cyclic_redundancy_checks#Reversed_representations_and_reciprocal_polynomials</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="#pkg-variables">Variables</a></li> -<li><a href="#Checksum">func Checksum(data []byte, tab *Table) uint32</a></li> -<li><a href="#ChecksumIEEE">func ChecksumIEEE(data []byte) uint32</a></li> -<li><a href="#New">func New(tab *Table) hash.Hash32</a></li> -<li><a href="#NewIEEE">func NewIEEE() hash.Hash32</a></li> -<li><a href="#Update">func Update(crc uint32, tab *Table, p []byte) uint32</a></li> -<li><a href="#Table">type Table</a></li> -<li> <a href="#MakeTable">func MakeTable(poly uint32) *Table</a> -</li> -</ul> <div id="pkg-examples"> <h3>Examples</h3> <dl> <dd><a class="exampleLink" href="#example_MakeTable">MakeTable</a></dd> </dl> </div> <h3>Package files</h3> <p> <span>crc32.go</span> <span>crc32_amd64.go</span> <span>crc32_generic.go</span> </p> <h2 id="pkg-constants">Constants</h2> <p>Predefined polynomials. </p> -<pre data-language="go">const ( - // IEEE is by far and away the most common CRC-32 polynomial. - // Used by ethernet (IEEE 802.3), v.42, fddi, gzip, zip, png, ... - IEEE = 0xedb88320 - - // Castagnoli's polynomial, used in iSCSI. - // Has better error detection characteristics than IEEE. - // https://dx.doi.org/10.1109/26.231911 - Castagnoli = 0x82f63b78 - - // Koopman's polynomial. - // Also has better error detection characteristics than IEEE. - // https://dx.doi.org/10.1109/DSN.2002.1028931 - Koopman = 0xeb31d82e -)</pre> <p>The size of a CRC-32 checksum in bytes. </p> -<pre data-language="go">const Size = 4</pre> <h2 id="pkg-variables">Variables</h2> <p>IEEETable is the table for the <a href="#IEEE">IEEE</a> polynomial. </p> -<pre data-language="go">var IEEETable = simpleMakeTable(IEEE)</pre> <h2 id="Checksum">func <span>Checksum</span> </h2> <pre data-language="go">func Checksum(data []byte, tab *Table) uint32</pre> <p>Checksum returns the CRC-32 checksum of data using the polynomial represented by the <a href="#Table">Table</a>. </p> -<h2 id="ChecksumIEEE">func <span>ChecksumIEEE</span> </h2> <pre data-language="go">func ChecksumIEEE(data []byte) uint32</pre> <p>ChecksumIEEE returns the CRC-32 checksum of data using the <a href="#IEEE">IEEE</a> polynomial. </p> -<h2 id="New">func <span>New</span> </h2> <pre data-language="go">func New(tab *Table) hash.Hash32</pre> <p>New creates a new <span>hash.Hash32</span> computing the CRC-32 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 Hash32 also implements <span>encoding.BinaryMarshaler</span> and <span>encoding.BinaryUnmarshaler</span> to marshal and unmarshal the internal state of the hash. </p> -<h2 id="NewIEEE">func <span>NewIEEE</span> </h2> <pre data-language="go">func NewIEEE() hash.Hash32</pre> <p>NewIEEE creates a new <span>hash.Hash32</span> computing the CRC-32 checksum using the <a href="#IEEE">IEEE</a> polynomial. Its Sum method will lay the value out in big-endian byte order. The returned Hash32 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 uint32, tab *Table, p []byte) uint32</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]uint32</pre> <h3 id="MakeTable">func <span>MakeTable</span> </h3> <pre data-language="go">func MakeTable(poly uint32) *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> <h4 id="example_MakeTable"> <span class="text">Example</span> -</h4> <p>Code:</p> <pre class="code" data-language="go">// In this package, the CRC polynomial is represented in reversed notation, -// or LSB-first representation. -// -// LSB-first representation is a hexadecimal number with n bits, in which the -// most significant bit represents the coefficient of x⁰ and the least significant -// bit represents the coefficient of xⁿ⁻¹ (the coefficient for xⁿ is implicit). -// -// For example, CRC32-Q, as defined by the following polynomial, -// x³²+ x³¹+ x²⁴+ x²²+ x¹⁶+ x¹⁴+ x⁸+ x⁷+ x⁵+ x³+ x¹+ x⁰ -// has the reversed notation 0b11010101100000101000001010000001, so the value -// that should be passed to MakeTable is 0xD5828281. -crc32q := crc32.MakeTable(0xD5828281) -fmt.Printf("%08x\n", crc32.Checksum([]byte("Hello world"), crc32q)) -</pre> <p>Output:</p> <pre class="output" data-language="go">2964d064 -</pre><div class="_attribution"> - <p class="_attribution-p"> - © Google, Inc.<br>Licensed under the Creative Commons Attribution License 3.0.<br> - <a href="http://golang.org/pkg/hash/crc32/" class="_attribution-link">http://golang.org/pkg/hash/crc32/</a> - </p> -</div> |
