XU XUv0.16.0

#hash/maphash

导入方式: #hash/maphash

公开 API: 3 函数, 5 方法, 1 类型, 0 常量, 0 方法集

显式 seed 的可移植字节哈希(非硬件 AES 位型)。

bytes

XuAPI
pub fn bytes(seed int, data &string) int

用途

返回已缓冲的字节串。

参数

seed int
随机种子(int)
data &string
数据(只读借用,调用方仍持有原值;类型 &string)

返回值

int — 该类型的值

of_string

XuAPI
pub fn of_string(seed int, s &string) int

用途

执行 of string 操作。

参数

seed int
随机种子(int)
s &string
源字符串(只读借用,调用方仍持有原值;类型 &string)

返回值

int — 该类型的值

struct Hash

XuAPI
pub struct Hash {
    pub seed int
    pub state int
    pub n int
}

用途

承载 seed、state、n 等属性的结构体。

公开字段

seed int
随机种子
state int
字段(int)
n int
数量、长度或上限

new

XuAPI
pub fn new(seed int) Hash

用途

构造该类型的新值。

参数

seed int
随机种子(int)

返回值

Hash — 该类型的值

($&Hash) set_seed

XuAPI
pub fn (h $&Hash) set_seed(seed int)

用途

$&Hash 上的操作:设置 seed。

参数

h $&Hash
本次调用使用的 Hash 实例;以独占借用传入,方法可修改它,调用方仍持有实例。
seed int
随机种子(int)

返回值

不返回值。

($&Hash) reset

XuAPI
pub fn (h $&Hash) reset()

用途

$&Hash 上的操作:清空内部状态,可再写入或读取。

参数

h $&Hash
本次调用使用的 Hash 实例;以独占借用传入,方法可修改它,调用方仍持有实例。

返回值

不返回值。

($&Hash) write

XuAPI
pub fn (h $&Hash) write(p &string) int

用途

$&Hash 上的操作:写入数据,返回写入的字节数。

参数

h $&Hash
本次调用使用的 Hash 实例;以独占借用传入,方法可修改它,调用方仍持有实例。
p &string
p(只读借用,调用方仍持有原值;类型 &string)

返回值

int — 写入的字节数

(Hash) sum64

XuAPI
pub fn (h Hash) sum64() int

用途

Hash 上的操作:计算摘要(多为小写 hex)。

参数

h Hash
本次调用使用的 Hash 实例;按值接收。

返回值

int — 该类型的值

(Hash) seed

XuAPI
pub fn (h Hash) seed() int

用途

Hash 上的操作:种子。

参数

h Hash
本次调用使用的 Hash 实例;按值接收。

返回值

int — 该类型的值