XU XUv0.8.8
中文

API

#crypto/rc4

import: #crypto/rc4

counts: 1 fns, 1 methods, 1 types, 0 consts, 0 ifaces

RC4 stream cipher. Broken; kept for protocol interop only.

struct Cipher

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

Purpose

RC4 stream cipher aligned with `crypto/rc4` NewCipher + XORKeyStream. Key 1..256 bytes. State is a 256-byte S-box plus i/j. XOR produces a new owning string ( writes in place). Not constant-time; RC4 is cryptographically broken — this is for protocol interop only.

Parameters

s []int
source string
i int
index or integer
j int
index

new_cipher

XuAPI
pub fn new_cipher(key &string) Cipher

Purpose

Construct cipher. Throws on failure.

Parameters

key &string
key (borrowed; caller keeps it; type &string)

Returns

Cipher — a value of this type

(&mut Cipher) xor_key_stream

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

Purpose

Method on `&mut Cipher`: xor key stream.

Parameters

c &mut Cipher
receiver &mut Cipher (exclusive borrow)
src &string
source (borrowed; caller keeps it; type &string)

Returns

string — result string