#crypto/hmac
Xu 0.16.0 API
import: #crypto/hmac
counts: 6 functions, 6 methods, 1 types, 0 constants, 0 method sets
HMAC-SHA-256 and HMAC-SM3.
sum256
pub fn sum256(key &string, data &string) string
Purpose
Compute a digest (often lowercase hex).
Parameters
key &string- key (read-only borrow; caller keeps the original; type &string)
data &string- data (read-only borrow; caller keeps the original; type &string)
Returns
string — result string
sum256_bytes
pub fn sum256_bytes(key &string, data &string) string
Purpose
Raw SHA-256 tag for protocol encodings and key derivation.
Parameters
key &string- key (read-only borrow; caller keeps the original; type &string)
data &string- data (read-only borrow; caller keeps the original; type &string)
Returns
string — result string
sum_sm3
pub fn sum_sm3(key &string, data &string) string
Purpose
Digest sm3.
Parameters
key &string- key (read-only borrow; caller keeps the original; type &string)
data &string- data (read-only borrow; caller keeps the original; type &string)
Returns
string — result string
equal
pub fn equal(a &string, b &string) bool
Purpose
Report whether the two values are equal.
Parameters
a &string- value (read-only borrow; caller keeps the original; type &string)
b &string- b (read-only borrow; caller keeps the original; type &string)
Returns
bool — true or false
struct Digest
Purpose
Hmac Cryptographic hash digest state context.
Public fields
This type has no public fields.
new256
pub fn new256(key &string) Digest
Purpose
Create 256-bit hash or HMAC digest context.
Parameters
key &string- key (read-only borrow; caller keeps the original; type &string)
Returns
Digest — a value of this type
new_sm3
pub fn new_sm3(key &string) Digest
Purpose
Construct sm3.
Parameters
key &string- key (read-only borrow; caller keeps the original; type &string)
Returns
Digest — a value of this type
($&Digest) write
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_bytes
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
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
($&Digest) reset
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
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
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