XU XUv0.16.0

#hash/crc64

import: #hash/crc64

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

ISO/ECMA CRC-64.

const ISO

XuAPI
pub const ISO = -2882303761517117440

Purpose

Constant ISO, defining protocol or algorithm parameters.

const ECMA

XuAPI
pub const ECMA = -3932672073523589310

Purpose

Constant ECMA, 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(crc int, tab &Table, data &string) int

Purpose

Execute update.

Parameters

crc int
crc (int)
tab &Table
tab (read-only borrow; caller keeps the original; type &Table)
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
}

Purpose

Crc64 Cryptographic hash digest state context.

Public fields

tab Table
field (Table)
crc int
field (int)

new_iso

XuAPI
pub fn new_iso() Digest

Purpose

Construct iso.

Parameters

No arguments are required.

Returns

Digest — a value of this type

new_ecma

XuAPI
pub fn new_ecma() Digest

Purpose

Construct ecma.

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_iso

XuAPI
pub fn checksum_iso(data &string) int

Purpose

Compute CRC-64 checksum using ISO polynomial.

Parameters

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

Returns

int — a value of this type

checksum_ecma

XuAPI
pub fn checksum_ecma(data &string) int

Purpose

Compute CRC-64 checksum using ECMA polynomial.

Parameters

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

Returns

int — a value of this type