cryptopals/examples/set1_7/main.rs
2023-04-26 21:58:19 -07:00

19 lines
627 B
Rust

#![feature(array_chunks)]
use aes::{cipher::{KeyInit, generic_array::GenericArray, Key, BlockEncrypt, BlockDecrypt}, Aes128, Block};
use cryptopals::{prelude::*, bvec, bvec64};
fn main() {
let key: Key<Aes128> = GenericArray::from(*b"YELLOW SUBMARINE");
let aes = aes::Aes128::new(&key);
let input = bvec64!("input.txt");
let mut output = Vec::new();
for chunk in input.array_chunks::<16>() {
let mut block: Block = GenericArray::from(*chunk);
aes.decrypt_block(&mut block);
output.extend(<[u8; 16]>::from(block));
}
dbg!(output.to_text().unwrap());
println!("pass")
}