Home
Insert
Update snippet 'CRC-32 implementation '
Title
Description
An implementation of a CRC-32 algorithm, as described in RFC-1952 "GZIP file format specification version 4.3"
Source code
module private Internal = let crcTable = let inline nextValue acc = if 0u <> (acc &&& 1u) then 0xedb88320u ^^^ (acc >>> 1) else acc >>> 1 let rec iter k acc = if k = 0 then acc else iter (k-1) (nextValue acc) [| 0u .. 255u |] |> Array.map (iter 8) /// Returns the CRC-32 value of 'name' as specified by RFC1952 let crc32 (name:string) = let inline update acc (ch:char) = Internal.crcTable.[int32 ((acc ^^^ (uint32 ch)) &&& 0xffu)] ^^^ (acc >>> 8) 0xFFffFFffu ^^^ Seq.fold update 0xFFffFFffu name
Tags
crc
crc
Author
Link
Reference NuGet packages
If your snippet has external dependencies, enter the names of NuGet packages to reference, separated by a comma (
#r
directives are not required).
Update