feistel

Crates.iofeistel
lib.rsfeistel
version0.1.0
sourcesrc
created_at2024-12-11 22:43:50.854814
updated_at2024-12-11 22:43:50.854814
descriptionGeneric Feistel Cipher
homepage
repositoryhttps://github.com/parrrate/feistel
max_upload_size
id1480589
size30,088
AF (timotheyca)

documentation

https://docs.rs/feistel

README

Generic implementation of a Feistel Cipher

let network = key
    .chunks_exact(4)
    .map(|chunk| {
        move |half: &XorArray<u8, ConstArrayLength<32>>| {
            let mut hasher = Sha256::new();
            hasher.update(half);
            hasher.update(chunk);
            let value: [u8; 32] = hasher.finalize().into();
            XorArray(value.into())
        }
    })
    .feistel_symmetric();
let original = [0; 64].into();
let encrypted = network.clone().array_encrypt(original);
assert_ne!(original, encrypted);
let decrypted = network.clone().array_decrypt(encrypted);
assert_eq!(original, decrypted);
Commit count: 12

cargo fmt