mirror of
https://bitbucket.org/Mattrixwv/cipherstream.git
synced 2025-12-06 18:33:58 -05:00
Fixed warning about comparing signed and unsigned integer types
This commit is contained in:
@@ -35,7 +35,7 @@ void Vigenere::setInputString(std::string input){
|
||||
inputString = "";
|
||||
|
||||
//Loop through every character in input. Remove all whitespace and punctuation and make sure all letters are capital and add it to inputString
|
||||
for(int cnt = 0;cnt < input.size();++cnt){
|
||||
for(unsigned int cnt = 0;cnt < input.size();++cnt){
|
||||
char letter = input[cnt];
|
||||
if(isupper(letter)){
|
||||
inputString += letter;
|
||||
@@ -74,7 +74,7 @@ void Vigenere::setKeyword(std::string key){
|
||||
//Make sure the keyword is blank
|
||||
keyword = "";
|
||||
//Loop through every letter in the key and make sure all of them are uppercase letters
|
||||
for(int cnt = 0;cnt < key.size();++cnt){
|
||||
for(unsigned int cnt = 0;cnt < key.size();++cnt){
|
||||
char letter = key[cnt];
|
||||
if(isupper(letter)){
|
||||
keyword += letter;
|
||||
@@ -134,7 +134,7 @@ std::string Vigenere::encode(){
|
||||
outputString.reserve(inputString.size());
|
||||
|
||||
//Step through every charater in the inputString and advance it the correct amount, according to offset
|
||||
for(int cnt = 0;cnt < inputString.size();++cnt){
|
||||
for(unsigned int cnt = 0;cnt < inputString.size();++cnt){
|
||||
char letter = (inputString[cnt] + offset[cnt % offset.size()]); //By using % you allow it to loop without having a separate counter
|
||||
//Make sure the character is still a letter, if not, wrap around
|
||||
if(letter < 'A'){
|
||||
@@ -174,7 +174,7 @@ std::string Vigenere::decode(){
|
||||
outputString.reserve(inputString.size());
|
||||
|
||||
//Step through every charater in the inputString and reduce it the correct amount, according to offset
|
||||
for(int cnt = 0;cnt < inputString.size();++cnt){
|
||||
for(unsigned int cnt = 0;cnt < inputString.size();++cnt){
|
||||
char letter = (inputString[cnt] - offset[cnt % offset.size()]); //By using % you allow it to loop without having a separate counter
|
||||
if(letter < 'A'){
|
||||
letter += 26;
|
||||
|
||||
Reference in New Issue
Block a user