Function rc5_cipher::rc5::encode
source · pub fn encode<W, const T: usize>(
key: Vec<u8>,
pt: Vec<u8>
) -> Result<Vec<u8>, Error>where
W: Unsigned,
for<'a> &'a [u8]: TryInto<W::Array>,Expand description
Encrypts a plaintext pt and returns a ciphertext ct.
The pt should have length 2 * w = 2 * bytes(W)
W: is the data type. Currently supported: u8, u16, u32, u64, u128
T: is the key expansion length T = 2 * (r + 1) being r number of
rounds. T should be even.
Example:
use rc5_cipher::encode;
let key = vec![0x00, 0x01, 0x02, 0x03];
let pt = vec![0x00, 0x01];
let ct = vec![0x21, 0x2A];
let res = encode::<u8, 26>(key, pt).unwrap();
assert!(&ct[..] == &res[..]);