From f17af835d4f414cba0932d8b8093f998fe602b9c Mon Sep 17 00:00:00 2001 From: datalore Date: Tue, 24 Oct 2023 21:38:29 +0200 Subject: [PATCH] Added tolower() calls --- brute.cc | 2 +- shift.cc | 3 ++- vigenere.cc | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/brute.cc b/brute.cc index 9a8a8c3..6785227 100644 --- a/brute.cc +++ b/brute.cc @@ -5,7 +5,7 @@ void shift(char* text, int key) std::cout << key << ": "; for(int i = 0; text[i] != 0; ++i) { - char c = text[i]-key; + char c = std::tolower(text[i])-key; if(c < 'a') c+=26; if(c > 'z') c-=26; std::cout << c; diff --git a/shift.cc b/shift.cc index 1c4d859..d7e2ee7 100644 --- a/shift.cc +++ b/shift.cc @@ -1,4 +1,5 @@ #include +#include int main(int argc, char** argv) { @@ -14,7 +15,7 @@ int main(int argc, char** argv) for(int i = 0; text[i] != 0; ++i) { - char c = text[i]+key; + char c = std::tolower(text[i])+key; if(c < 'a') c+=26; if(c > 'z') c-=26; std::cout << c; diff --git a/vigenere.cc b/vigenere.cc index 2c3b229..9bdc885 100644 --- a/vigenere.cc +++ b/vigenere.cc @@ -2,7 +2,7 @@ int keyvalue(char c) { - return c - 'a'; + return std::tolower(c) - 'a'; } int main(int argc, char** argv) { @@ -20,7 +20,7 @@ int main(int argc, char** argv) int ki = 0; for(int pi = 0; text[pi] != 0; ++pi) { - char c = text[pi] + keyvalue(key[ki]); + char c = std::tolower(text[pi]) + keyvalue(key[ki]); if(c < 'a') c+=26; if(c > 'z') c-=26; std::cout << c;