XU XUv0.8.8
EN

API

#crypto/des

import: #crypto/des

counts: 2 函数, 5 方法, 2 类型, 1 常量, 0 方法集

DES / 3DES-EDE 单块。

const block_size

XuAPI
pub const block_size = 8

用途

公开常量 `block_size`。 值为 `8`

参数

无

struct Cipher

XuAPI
pub struct Cipher {
    pub subkeys []int
}

用途

公开结构体 `Cipher`。

参数

subkeys []int
字段([]int)

struct TripleCipher

XuAPI
pub struct TripleCipher {
    pub k1 []int
    pub k2 []int
    pub k3 []int
}

用途

公开结构体 `TripleCipher`。

参数

k1 []int
字段([]int)
k2 []int
字段([]int)
k3 []int
字段([]int)

new_cipher

XuAPI
pub fn new_cipher(key &string) Cipher

用途

构造 cipher。失败时 throw。

参数

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

返回

Cipher — 该类型的值

(&Cipher) block_size

XuAPI
pub fn (c &Cipher) block_size() int

用途

`&Cipher` 上的方法:块尺寸。

参数

c &Cipher
接收者 &Cipher(借用)

返回

int — 该类型的值

(&Cipher) encrypt

XuAPI
pub fn (c &Cipher) encrypt(src &string) string

用途

`&Cipher` 上的方法:加密。

参数

c &Cipher
接收者 &Cipher(借用)
src &string
源数据(借用,调用方仍持有;类型 &string)

返回

string — 结果字符串

(&Cipher) decrypt

XuAPI
pub fn (c &Cipher) decrypt(src &string) string

用途

`&Cipher` 上的方法:解密。

参数

c &Cipher
接收者 &Cipher(借用)
src &string
源数据(借用,调用方仍持有;类型 &string)

返回

string — 结果字符串

new_triple_cipher

XuAPI
pub fn new_triple_cipher(key &string) TripleCipher

用途

构造 triple cipher。失败时 throw。

参数

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

返回

TripleCipher — 该类型的值

(&TripleCipher) encrypt

XuAPI
pub fn (c &TripleCipher) encrypt(src &string) string

用途

`&TripleCipher` 上的方法:加密。

参数

c &TripleCipher
接收者 &TripleCipher(借用)
src &string
源数据(借用,调用方仍持有;类型 &string)

返回

string — 结果字符串

(&TripleCipher) decrypt

XuAPI
pub fn (c &TripleCipher) decrypt(src &string) string

用途

`&TripleCipher` 上的方法:解密。

参数

c &TripleCipher
接收者 &TripleCipher(借用)
src &string
源数据(借用,调用方仍持有;类型 &string)

返回

string — 结果字符串