Module: crypto.crc32

Source: ./crypto/crc32.reef


Overview

crypto/crc32 - CRC32 checksum calculation

Implements CRC-32 (IEEE 802.3 polynomial) checksum algorithm. Uses table-driven implementation for efficiency.

Usage: import crypto.crc32 let checksum = crc32("Hello, World!") let hex = crc32_hex("Hello, World!") // "EC4AC3D0"


Functions

fn crc32_byte(crc: int, b: int): int

Compute CRC for one byte using bit-by-bit method Works with signed 32-bit int but treats bit patterns as unsigned

fn crc32_init(): int

Initialize CRC state

fn crc32_update_byte(crc: int, b: int): int

Update CRC with a single byte

fn crc32_update(crc: int, data: string): int

Update CRC with string data

fn crc32_finalize(crc: int): int

Finalize CRC (XOR with 0xFFFFFFFF = -1 in signed 32-bit)

fn crc32(data: string): int

Calculate CRC32 of a string

fn crc32_bytes(data: [int], len: int): int

Calculate CRC32 of a byte array

fn crc32_hex(data: string): string

Calculate CRC32 and return as uppercase hex string

fn crc32_hex_lower(data: string): string

Calculate CRC32 and return as lowercase hex string

fn crc32_binary(data: [uint8]): int

Calculate CRC32 of a byte array (handles null bytes)

fn crc32_binary_hex(data: [uint8]): string

Calculate CRC32 of byte array and return as uppercase hex string

fn crc32_binary_hex_lower(data: [uint8]): string

Calculate CRC32 of byte array and return as lowercase hex string

fn get_hex_digits_upper(): string

fn get_hex_digits_lower(): string

fn int_to_hex_upper(n: int): string

Convert 32-bit integer to 8-character uppercase hex string Works with signed int by treating bit pattern as unsigned

fn int_to_hex_lower(n: int): string

Convert 32-bit integer to 8-character lowercase hex string


Generated by reefc doc