Module std.digest.crc
Cyclic Redundancy Check (32-bit) implementation.
| Category | Functions |
|---|---|
| Template API | CRC32
|
| OOP API | CRC32Digest |
| Helpers | crcHexString crc32Of |
This module conforms to the APIs defined in . To understand the
differences between the template and the OOP API, see std.digest.digest.
std.digest.digest
This module publicly imports and can be used as a stand-alone
module.
std.digest.digest
Note
CRCs are usually printed with the MSB first. When using
std.digest.digest.toHexString the result will be in an unexpected
order. Use std.digest.digest.toHexString's optional order parameter
to specify decreasing order for the correct result. The crcHexString
alias can also be used for this purpose.
References
Standards
Implements the 'common' IEEE CRC32 variant
(LSB-first order, Initial value uint.max, complement result)
CTFE
Digests do not work in CTFE
Example
//Template API import std.digest.crc; ubyte[4] hash = crc32Of("The quick brown fox jumps over the lazy dog"); assert(crcHexString(hash) == "414FA339"); //Feeding data ubyte[1024] data; CRC32 crc; crc.put(data[]); crc.start(); //Start again crc.put(data[]); hash = crc.finish();
Example
//OOP API import std.digest.crc; auto crc = new CRC32Digest(); ubyte[] hash = crc.digest("The quick brown fox jumps over the lazy dog"); assert(crcHexString(hash) == "414FA339"); //352441c2 //Feeding data ubyte[1024] data; crc.put(data[]); crc.reset(); //Start again crc.put(data[]); hash = crc.finish();
Functions
| Name | Description |
|---|---|
crc32Of
|
This is a convenience alias for std.digest.digest.digest using the
CRC32 implementation.
|
Structs
| Name | Description |
|---|---|
CRC32
|
Template API CRC32 implementation.
See for differences between template and OOP API.
|
Aliases
| Name | Type | Description |
|---|---|---|
CRC32Digest
|
WrapperDigest!(std.digest.crc.CRC32)
|
OOP API CRC32 implementation.
See for differences between template and OOP API.
|
crcHexString
|
This is a convenience alias for std.digest.digest.toHexString
producing the usual CRC32 string output.
|
Authors
Pavel "EvilOne" Minayev, Alex Rønne Petersen, Johannes Pfau