summaryrefslogtreecommitdiffstats
path: root/src/lib.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2015-03-15 16:22:13 -0400
committerJesse Luehrs <doy@tozt.net>2015-03-15 16:22:13 -0400
commitd6578f1357f7ae10feb9e4a4fae1a1953739557a (patch)
treefc2df284ecbdd029715deeec1e324f79492b7beb /src/lib.rs
parentea9be053977c5730c8440685437abf0230062bb5 (diff)
downloadmatasano-d6578f1357f7ae10feb9e4a4fae1a1953739557a.tar.gz
matasano-d6578f1357f7ae10feb9e4a4fae1a1953739557a.zip
if we disallow control characters, we get much more reasonable results
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
index e7f695d..9506289 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -191,6 +191,9 @@ fn crack_single_byte_xor_with_confidence (input: &[u8]) -> (u8, f64) {
if !decrypted.is_ascii() {
continue;
}
+ if decrypted.iter().any(|&c| c != b'\n' && (c < 0x20 || c > 0x7E)) {
+ continue;
+ }
let lowercase = decrypted.to_ascii_lowercase();
let mut frequencies = [0; 26];
let mut total_frequency = 0;