XU XUv0.16.0

#crypto/sm3

import: #crypto/sm3

counts: 5 functions, 6 methods, 1 types, 0 constants, 0 method sets

SM3 digest. Pure Xu, not commercial-crypto certified.

struct Digest

XuAPI
pub struct Digest {

}

Purpose

Sm3 Cryptographic hash digest state context.

Public fields

This type has no public fields.

new

XuAPI
pub fn new() Digest

Purpose

Construct a new value of this type.

Parameters

No arguments are required.

Returns

Digest — a value of this type

empty

XuAPI
pub fn empty() Digest

Purpose

empty returns an inert Digest without allocating the 68-word schedule slice.

Parameters

No arguments are required.

Returns

Digest — a value of this type

sum_bytes

XuAPI
pub fn sum_bytes(s string) string

Purpose

Compute a raw-byte digest.

Parameters

s string
source string (string)

Returns

string — result string

sum_prefix_bytes

XuAPI
pub fn sum_prefix_bytes(s &string, n int) string

Purpose

Hash the first n bytes while reading/compressing a fixed shape determined solely by s.len. n and the bytes may be secret; 0 <= n <= s.len is required. CBC callers must also gather the received MAC without secret-indexed reads. Throws on failure; handle the error or propagate it to the caller.

Parameters

s &string
source string (read-only borrow; caller keeps the original; type &string)
n int
count, length, or limit (int)

Returns

string — result string

sum

XuAPI
pub fn sum(s string) string

Purpose

Compute a digest (often lowercase hex).

Parameters

s string
source string (string)

Returns

string — result string

($&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) 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.

(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 (value receiver).

Returns

int — a value of this type

(Digest) blocksize

XuAPI
pub fn (d Digest) blocksize() int

Purpose

Return block size of the cipher or stream in bytes.

Parameters

d Digest
The Digest instance used by this call (value receiver).

Returns

int — a value of this type

(&Digest) sum_bytes

XuAPI
pub fn (d &Digest) sum_bytes() string

Purpose

Operation on &Digest: compute a raw-byte digest.

Parameters

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

Returns

string — result string

(&Digest) sum

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

Purpose

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

Parameters

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

Returns

string — result string