crc32

uint
crc32

Parameters

s StreamInterface

The stream

Return Value

Type: uint

The CRC32 hash computed from a stream

Examples

import std.stdio: stdout, write, writeln;
import freck.streams.memorystream: MemoryStream;

write("Running CRC32 tests:"); stdout.flush;

foreach (str, result; [
	"Hello, teenage America": 0x11fa4292,
	"The quick brown fox jumps over the lazy dog": 0x414fa339,
	"hash me!": 0xdbc71824
]) {
	auto stream = MemoryStream.fromBytes(cast(ubyte[])(str));
	assert(stream.crc32 == result);
}

writeln(" OK");

Meta