XU XUv0.16.0

#hash/crc32

import: #hash/crc32

counts: 7 functions, 4 methods, 2 types, 3 constants, 0 method sets

IEEE/Castagnoli/Koopman CRC-32.

const IEEE

XuAPI
pub const IEEE = 3988292384

Purpose

Constant IEEE, defining protocol or algorithm parameters.

const CASTAGNOLI

XuAPI
pub const CASTAGNOLI = 2197175160

Purpose

Constant CASTAGNOLI, defining protocol or algorithm parameters.

const KOOPMAN

XuAPI
pub const KOOPMAN = 3945912366

Purpose

Constant KOOPMAN, defining protocol or algorithm parameters.

struct Table

XuAPI
pub struct Table {
    pub entries [256]int
}

Purpose

Structure encapsulating entries.

Public fields

entries [256]int
field ([256]int)

make_table

XuAPI
pub fn make_table(poly int) Table

Purpose

Build 256-entry CRC lookup table from polynomial.

Parameters

poly int
poly (int)

Returns

Table — a value of this type

update

XuAPI
pub fn update(tab &Table, crc int, data &string) int

Purpose

Execute update.

Parameters

tab &Table
tab (read-only borrow; caller keeps the original; type &Table)
crc int
crc (int)
data &string
data (read-only borrow; caller keeps the original; type &string)

Returns

int — a value of this type

checksum

XuAPI
pub fn checksum(data &string, tab &Table) int

Purpose

Compute the 32-bit checksum of the data.

Parameters

data &string
data (read-only borrow; caller keeps the original; type &string)
tab &Table
tab (read-only borrow; caller keeps the original; type &Table)

Returns

int — a value of this type

struct Digest

XuAPI
pub struct Digest {
    pub tab Table
    pub crc int
    pub is_ieee bool
}

Purpose

Crc32 Cryptographic hash digest state context.

Public fields

tab Table
field (Table)
crc int
field (int)
is_ieee bool
field (bool)

new_ieee

XuAPI
pub fn new_ieee() Digest

Purpose

Construct ieee.

Parameters

No arguments are required.

Returns

Digest — a value of this type

($&Digest) write

XuAPI
pub fn (d $&Digest) write(p &string) int

Purpose

Operation on $&Digest: write data and return the byte count.

Parameters

d $&Digest
The Digest instance used by this call (exclusive borrow).
p &string
p (read-only borrow; caller keeps the original; type &string)

Returns

int — bytes written

(&Digest) sum

XuAPI
pub fn (d &Digest) sum() int

Purpose

Operation on &Digest: compute a digest (often lowercase hex).

Parameters

d &Digest
The Digest instance used by this call (borrow).

Returns

int — a value of this type

(&Digest) size

XuAPI
pub fn (d &Digest) size() int

Purpose

Operation on &Digest: return the size.

Parameters

d &Digest
The Digest instance used by this call (borrow).

Returns

int — a value of this type

($&Digest) reset

XuAPI
pub fn (d $&Digest) reset()

Purpose

Operation on $&Digest: clear internal state so the value can be reused.

Parameters

d $&Digest
The Digest instance used by this call (exclusive borrow).

Returns

This call does not return a value.

checksum_ieee

XuAPI
pub fn checksum_ieee(data &string) int

Purpose

Compute CRC-32 checksum using IEEE polynomial.

Parameters

data &string
data (read-only borrow; caller keeps the original; type &string)

Returns

int — a value of this type

checksum_castagnoli

XuAPI
pub fn checksum_castagnoli(data &string) int

Purpose

Compute CRC-32C checksum using Castagnoli polynomial.

Parameters

data &string
data (read-only borrow; caller keeps the original; type &string)

Returns

int — a value of this type

checksum_koopman

XuAPI
pub fn checksum_koopman(data &string) int

Purpose

Compute CRC-32 checksum using Koopman polynomial.

Parameters

data &string
data (read-only borrow; caller keeps the original; type &string)

Returns

int — a value of this type