use common::{alphabet, substitute};
use common::alphabet::Alphabet;
pub fn apply(message: &str) -> String {
substitute::shift_substitution(message,
|i| alphabet::STANDARD.modulo((i + 13) as isize)).unwrap()
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn with_utf8(){
let message = "Peace, Freedom and Liberty! 🗡️";
let encrypted = apply(message);
let decrypted = apply(&encrypted);
assert_eq!(decrypted, message);
}
#[test]
fn alphabet_encrypt(){
let message = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
let encrypted = apply(message);
let decrypted = apply(&encrypted);
assert_eq!(decrypted, message);
}
}