crc32

    CRC32 checksum implementation

    crc32
    checksum
    hash
    Download zip
    Version
    0.1.1
    License
    MIT
    Last updated
    3 months ago
    Downloads
    30

    #kujirahand/crc32

    This is a simple CRC32 implementation in MoonBit. It provides both a one-shot checksum function and a streaming CRC32Stream struct for incremental updates.

    #Add to your project

    To use this package in your MoonBit project, run:

    moon add kujirahand/crc32

    And import this package in your moon.pkg:

    import {
    "kujirahand/crc32" @crc32
    }

    #Usage

    Simply call the checksum function with your data:

    ///|
    fn main {
    println(@crc32.checksum(b"hello")) // 907060870
    println(@crc32.checksum(b"dog")) // 2167159165
    }

    For streaming updates, create a CRC32Stream and call update with new data:

    fn main {
    // Stream example
    let mut stream = @crc32.CRC32Stream::new()
    stream = stream.update(b"hello")
    println(stream.finalize()) // 907060870
    }

    CRC32Stream

    pub(all) struct CRC32Stream {
    crc : UInt
    } derive(Eq,
    Debug
    )

    CRC32 checksum stream implementation

    CRC32Stream::finalize

    fn CRC32Stream::finalize(self : CRC32Stream) -> UInt

    Finalize the CRC32Stream and get the final CRC value

    CRC32Stream::new

    Create a new CRC32Stream with initial CRC value

    CRC32Stream::update

    fn CRC32Stream::update(self : CRC32Stream, bytes : Bytes) -> CRC32Stream

    Update the CRC32Stream with new bytes

    checksum

    fn checksum(bytes : Bytes) -> UInt

    CRC32 checksum implementation (optimized with loop unrolling)

    checksum_basic

    fn checksum_basic(bytes : Bytes) -> UInt

    CRC32 checksum basic implementation

    Source Files

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io