XU XUv0.16.0

#crypto/rc4

导入方式: #crypto/rc4

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

RC4 流密码。算法已破,仅协议互通。

struct Cipher

XuAPI
pub struct Cipher {
    pub s []int
    pub i int
    pub j int
}

用途

Rc4 密码算法的分组或流式加解密上下文。

公开字段

s []int
源字符串
i int
下标或整数
j int
下标

new_cipher

XuAPI
pub fn new_cipher(key &string) Cipher

用途

构造 cipher。失败时抛出错误,调用方需处理或继续传播。

参数

key &string
键(只读借用,调用方仍持有原值;类型 &string)

返回值

Cipher — 该类型的值

($&Cipher) xor_key_stream

XuAPI
pub fn (c $&Cipher) xor_key_stream(src &string) string

用途

$&Cipher 上的操作:执行 xor key stream 操作。

参数

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

返回值

string — 结果字符串