Skip to content
FutureBlitz

    Install

    Import std.crypto.checksums

    std.crypto.checksums

    Crc32 and XxHash: fast checksums that aren't cryptographic. They catch accidents, like a file that was cut short or a bit that flipped, but not an attacker, who can make data with any of them; that takes a hash, like Sha256 or Blake3. Crc32 is CRC-32 as zlib, Zip, PNG, and Ethernet have it; XxHash is xxHash's XXH3, 64 bits, with a seed.

    std/crypto/checksums.fb

    Types

    Crc32 class

    Public Class Crc32

    CRC-32 of what's added in turn, a bit at a time, with the reversed polynomial 0xEDB88320.

    std/crypto/checksums.fb, line 19

    • Public New() constructor #

      A new Crc32, of nothing yet.

    • Public Static Method Hash(data: UInt8[]): UInt32 static method #

      The CRC-32 of data.

    • Public Static Method Hash(text: String): UInt32 static method #

      The CRC-32 of text's UTF-8 bytes.

    • Public Method Add(data: UInt8[]) method #

      Adds data to what it checks.

    • Public Method Add(text: String) method #

      Adds text's UTF-8 bytes to what it checks.

    • Public Method Finish(): UInt32 method #

      The CRC of what was added, after which it starts again, empty.

    XxHash class

    Public Class XxHash

    XXH3's 64-bit hash of what's added in turn, with a seed, so the same data hashes differently under different seeds.

    std/crypto/checksums.fb, line 62

    • Public New(seed: UInt64 = 0) constructor #

      A new XxHash, of nothing yet, with seed.

    • Public Static Method Hash(data: UInt8[], seed: UInt64 = 0): UInt64 static method #

      XXH3's 64-bit hash of data, with seed.

    • Public Static Method Hash(text: String, seed: UInt64 = 0): UInt64 static method #

      XXH3's 64-bit hash of text's UTF-8 bytes, with seed.

    • Public Method Add(data: UInt8[]) method #

      Adds data to what it hashes.

    • Public Method Add(text: String) method #

      Adds text's UTF-8 bytes to what it hashes.

    • Public Method Finish(): UInt64 method #

      The hash of what was added, after which it starts again, empty, with its seed.

    Report an issue with this page or with FutureBlitz on GitHub.