use std::path::Path; use mini_enigma::state_machine::Enigma; use super::load_enigma_settings; pub fn kat(path: P) where P: AsRef + std::fmt::Display + Copy, { let settings = load_enigma_settings(path); println!("Testing {} [{}]", settings.name, settings.date.unwrap_or(0)); let mut enigma = Enigma::new::(&settings.clone().into()); print!("input: "); let mut ct = String::new(); for (i, ch) in settings.plaintext.chars().enumerate() { let bit = enigma.encrypt_char(ch); ct.push(bit); print!("{ch}"); if settings.ciphertext.as_bytes()[i] as char != bit { println!("\noutput: {ct}"); println!("pos: {:?}", enigma.get_grundstellung()); } assert_eq!(settings.ciphertext.as_bytes()[i] as char, bit) } }