XU XUv0.8.8
中文

API

#crypto/cipher

import: #crypto/cipher

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

AES-CBC/CTR/GCM bound to crypto.aes.Cipher.

pad_pkcs7

XuAPI
pub fn pad_pkcs7(src &string, block_size int) string

Purpose

AES-CBC / AES-CTR / AES-GCM aligned with `crypto/cipher`. Bound to `aes.Cipher` (Xu has no cipher.Block interface). Bare CBC requires whole blocks; PKCS7 helpers pad/unpad. CTR is XOR of the AES keystream (big-endian counter). GCM: 96-bit nonce, 128-bit tag (seal_gcm / open_gcm). Throws on failure.

Parameters

src &string
source (borrowed; caller keeps it; type &string)
block_size int
block_size (int)

Returns

string — result string

unpad_pkcs7

XuAPI
pub fn unpad_pkcs7(src &string) string

Purpose

Unpad pkcs7. Throws on failure.

Parameters

src &string
source (borrowed; caller keeps it; type &string)

Returns

string — result string

encrypt_cbc

XuAPI
pub fn encrypt_cbc(c &aes.Cipher, iv &string, src &string) string

Purpose

Encrypt cbc. Throws on failure.

Parameters

c &aes.Cipher
byte or character code (borrowed; caller keeps it; type &aes.Cipher)
iv &string
int payload or initialization vector (borrowed; caller keeps it; type &string)
src &string
source (borrowed; caller keeps it; type &string)

Returns

string — result string

decrypt_cbc

XuAPI
pub fn decrypt_cbc(c &aes.Cipher, iv &string, src &string) string

Purpose

Decrypt cbc. Throws on failure.

Parameters

c &aes.Cipher
byte or character code (borrowed; caller keeps it; type &aes.Cipher)
iv &string
int payload or initialization vector (borrowed; caller keeps it; type &string)
src &string
source (borrowed; caller keeps it; type &string)

Returns

string — result string

encrypt_cbc_pkcs7

XuAPI
pub fn encrypt_cbc_pkcs7(c &aes.Cipher, iv &string, src &string) string

Purpose

Encrypt cbc pkcs7.

Parameters

c &aes.Cipher
byte or character code (borrowed; caller keeps it; type &aes.Cipher)
iv &string
int payload or initialization vector (borrowed; caller keeps it; type &string)
src &string
source (borrowed; caller keeps it; type &string)

Returns

string — result string

decrypt_cbc_pkcs7

XuAPI
pub fn decrypt_cbc_pkcs7(c &aes.Cipher, iv &string, src &string) string

Purpose

Decrypt cbc pkcs7.

Parameters

c &aes.Cipher
byte or character code (borrowed; caller keeps it; type &aes.Cipher)
iv &string
int payload or initialization vector (borrowed; caller keeps it; type &string)
src &string
source (borrowed; caller keeps it; type &string)

Returns

string — result string

encrypt_ctr

XuAPI
pub fn encrypt_ctr(c &aes.Cipher, iv &string, src &string) string

Purpose

Encrypt ctr.

Parameters

c &aes.Cipher
byte or character code (borrowed; caller keeps it; type &aes.Cipher)
iv &string
int payload or initialization vector (borrowed; caller keeps it; type &string)
src &string
source (borrowed; caller keeps it; type &string)

Returns

string — result string

decrypt_ctr

XuAPI
pub fn decrypt_ctr(c &aes.Cipher, iv &string, src &string) string

Purpose

Decrypt ctr.

Parameters

c &aes.Cipher
byte or character code (borrowed; caller keeps it; type &aes.Cipher)
iv &string
int payload or initialization vector (borrowed; caller keeps it; type &string)
src &string
source (borrowed; caller keeps it; type &string)

Returns

string — result string

seal_gcm

XuAPI
pub fn seal_gcm(c &aes.Cipher, nonce &string, plaintext &string, aad &string) string

Purpose

Seal gcm. Throws on failure.

Parameters

c &aes.Cipher
byte or character code (borrowed; caller keeps it; type &aes.Cipher)
nonce &string
nonce (borrowed; caller keeps it; type &string)
plaintext &string
plaintext (borrowed; caller keeps it; type &string)
aad &string
aad (borrowed; caller keeps it; type &string)

Returns

string — result string

open_gcm

XuAPI
pub fn open_gcm(c &aes.Cipher, nonce &string, sealed &string, aad &string) string

Purpose

Open gcm. Throws on failure.

Parameters

c &aes.Cipher
byte or character code (borrowed; caller keeps it; type &aes.Cipher)
nonce &string
nonce (borrowed; caller keeps it; type &string)
sealed &string
sealed (borrowed; caller keeps it; type &string)
aad &string
aad (borrowed; caller keeps it; type &string)

Returns

string — result string