Skip to content

Commit

Permalink
fixed issue where morse doesn't convert add space when decrypting
Browse files Browse the repository at this point in the history
  • Loading branch information
martial-plains committed Mar 11, 2024
1 parent 42922ec commit 27b3eef
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/ciphers/morse_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ pub fn decrypt(text: &str) -> String {
decrypted_text.push(*key);
}
}

if *split == "/" {
decrypted_text.push(' ');
}
}

decrypted_text
Expand All @@ -148,4 +152,12 @@ mod tests {
let decrypted = decrypt(&encrypted);
assert_eq!(text, decrypted);
}

#[test]
pub fn test_hello_world() {
let text = "hello world!";
let encrypted = encrypt(text);
let decrypted = decrypt(&encrypted);
assert_eq!(text, decrypted);
}
}

0 comments on commit 27b3eef

Please sign in to comment.