XU XUv0.16.0

#crypto/des

import: #crypto/des

counts: 2 functions, 5 methods, 2 types, 1 constants, 0 method sets

DES / 3DES-EDE single block.

const BLOCK_SIZE

XuAPI
pub const BLOCK_SIZE = 8

Purpose

Constant BLOCK_SIZE, defining protocol or algorithm parameters.

struct Cipher

XuAPI
pub struct Cipher {
    pub subkeys []int
}

Purpose

Des Cipher context for block or stream encryption/decryption.

Public fields

subkeys []int
field ([]int)

struct TripleCipher

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

Purpose

Des Cipher context for block or stream encryption/decryption.

Public fields

k1 []int
field ([]int)
k2 []int
field ([]int)
k3 []int
field ([]int)

new_cipher

XuAPI
pub fn new_cipher(key &string) Cipher

Purpose

Construct cipher. Throws on failure; handle the error or propagate it to the caller.

Parameters

key &string
key (read-only borrow; caller keeps the original; type &string)

Returns

Cipher — a value of this type

(&Cipher) block_size

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

Purpose

Operation on &Cipher: block size.

Parameters

c &Cipher
The Cipher instance used by this call (borrow).

Returns

int — a value of this type

(&Cipher) encrypt

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

Purpose

Operation on &Cipher: encrypt.

Parameters

c &Cipher
The Cipher instance used by this call (borrow).
src &string
source (read-only borrow; caller keeps the original; type &string)

Returns

string — result string

(&Cipher) decrypt

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

Purpose

Operation on &Cipher: decrypt.

Parameters

c &Cipher
The Cipher instance used by this call (borrow).
src &string
source (read-only borrow; caller keeps the original; type &string)

Returns

string — result string

new_triple_cipher

XuAPI
pub fn new_triple_cipher(key &string) TripleCipher

Purpose

Construct triple cipher. Throws on failure; handle the error or propagate it to the caller.

Parameters

key &string
key (read-only borrow; caller keeps the original; type &string)

Returns

TripleCipher — a value of this type

(&TripleCipher) encrypt

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

Purpose

Operation on &TripleCipher: encrypt. Throws on failure; handle the error or propagate it to the caller.

Parameters

c &TripleCipher
The TripleCipher instance used by this call (borrow).
src &string
source (read-only borrow; caller keeps the original; type &string)

Returns

string — result string

(&TripleCipher) decrypt

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

Purpose

Operation on &TripleCipher: decrypt. Throws on failure; handle the error or propagate it to the caller.

Parameters

c &TripleCipher
The TripleCipher instance used by this call (borrow).
src &string
source (read-only borrow; caller keeps the original; type &string)

Returns

string — result string