use crate::DecoderResult;
pub fn program_exiting_successful_decoding(result: DecoderResult) {
let config = crate::config::get_config();
if config.api_mode {
return;
}
let plaintext = result.text;
let decoded_path = result
.path
.iter()
.map(|c| c.decoder)
.collect::<Vec<_>>()
.join(" → ");
let decoded_path_coloured = ansi_term::Colour::Yellow.bold().paint(&decoded_path);
let decoded_path_string = if !decoded_path.contains('→') {
format!("the decoder used is {}", decoded_path_coloured)
} else {
format!("the decoders used are {}", decoded_path_coloured)
};
println!(
"The plaintext is: \n{}\nand {}",
ansi_term::Colour::Yellow.bold().paint(&plaintext[0]),
decoded_path_string
);
}
pub fn decoded_how_many_times(depth: u32) {
let config = crate::config::get_config();
if config.api_mode {
return;
}
let decoders = crate::filtration_system::filter_and_get_decoders(&DecoderResult::default());
let decoded_times_int = depth * (decoders.components.len() as u32 + 25);
let decoded_times_str = format!("{} times", decoded_times_int);
let time_took = calculate_time_took(decoded_times_int);
println!("\n🥳 Ares has decoded {} times.\nIf you would have used Ciphey, it would have taken you {}\n", decoded_times_str, time_took);
}
pub fn human_checker_check(description: &str, text: &str) {
println!(
"🕵️ I think the plaintext is {}.\nPossible plaintext: '{}' (y/N): ",
ansi_term::Colour::Yellow.bold().paint(description),
ansi_term::Colour::Yellow.bold().paint(text)
)
}
pub fn failed_to_decode() {
let config = crate::config::get_config();
if config.api_mode {
return;
}
println!("⛔️ Ares has failed to decode the text.");
println!("If you want more help, please ask in #coded-messages in our Discord http://discord.skerritt.blog");
}
fn calculate_time_took(decoded_times_int: u32) -> String {
let ciphey_decodings_a_second = 5;
let ciphey_how_long_to_decode_in_seconds = decoded_times_int / ciphey_decodings_a_second;
if ciphey_how_long_to_decode_in_seconds > 60 {
if ciphey_how_long_to_decode_in_seconds / 60 == 1 {
format!("{} minute", ciphey_how_long_to_decode_in_seconds / 60)
} else {
format!("{} minutes", ciphey_how_long_to_decode_in_seconds / 60)
}
} else {
format!("{} seconds", ciphey_how_long_to_decode_in_seconds)
}
}
pub fn countdown_until_program_ends(seconds_spent_running: u32, duration: u32) {
let config = crate::config::get_config();
if config.api_mode {
return;
}
if seconds_spent_running % 5 == 0 && seconds_spent_running != 0 {
let time_left = duration - seconds_spent_running;
if time_left == 0 {
return;
}
println!(
"{} seconds have passed. {} remaining",
seconds_spent_running, time_left
);
}
}
pub fn return_early_because_input_text_is_plaintext() {
let config = crate::config::get_config();
if config.api_mode {
return;
}
println!("Your input text is the plaintext 🥳");
}
pub fn panic_failure_both_input_and_fail_provided() {
let config = crate::config::get_config();
if config.api_mode {
return;
}
panic!("Failed -- both file and text were provided. Please only use one.")
}
pub fn panic_failure_no_input_provided() {
let config = crate::config::get_config();
if config.api_mode {
return;
}
panic!("Failed -- no input was provided. Please use -t for text or -f for files.")
}