diff --git a/include/playfair.h b/include/playfair.h index 51675d44d53931cfc77a9cbdccfb4962c74ef914..f2de87b9d7a74981a3bb7119faaab95291ca9ee1 100644 --- a/include/playfair.h +++ b/include/playfair.h @@ -2,6 +2,8 @@ #include <string> #include <vector> #include <iterator> +#include <sstream> +#include <cctype> std::vector< char > createKM ( const std::string key); std::string playfair(std::string text , const std::string key ); diff --git a/playfair.cpp b/playfair.cpp index 3bed308329bd8eaf1e144b4407d52d08f6ecb33e..87e18fabbe6127c5630349f7b7acd8e42002ac78 100644 --- a/playfair.cpp +++ b/playfair.cpp @@ -36,7 +36,6 @@ std::string playfair(std::string text, const std::string key){ } std::cout << std::endl; } - int indexT = -1; char fst = text[++indexT]; char snd = text[++indexT]; @@ -47,17 +46,6 @@ std::string playfair(std::string text, const std::string key){ int iFst, iSnd; - for (int i=0; i<25; ++i){ - if(mKey[i] == fst){ - iFst=i; - } - if(mKey[i] == snd){ - iSnd=i; - } - } - char retfst,retsnd; - retfst = mKey[iFst/5 + iSnd%5] - //TODO:change return text; } diff --git a/playunfair.cpp b/playunfair.cpp index 7ca0f88aa9ad178249a3fdb55a90be913a166d42..73f37507e14182b02b94ec04bc936986d2276774 100644 --- a/playunfair.cpp +++ b/playunfair.cpp @@ -1,8 +1,11 @@ #include "include/playfair.h" #include <fstream> -#include <vector> -#include <string> -#include <sstream> +#include <algorithm> + +void parser(std::string &text){ + text.erase(std::remove(text.begin(), text.end(), ' '), text.end()); + //for(const char & +} int main(int argc, char *argv[]){ if(argc!=3){ @@ -25,8 +28,9 @@ int main(int argc, char *argv[]){ while(std::getline(input, aux)) text << aux; - std::cout << text.str() << std::endl; - //chamar play fair passando string e chave - crip = playfair(text.str(), key); + crip = text.str(); + parser(crip); + std::cout << crip << std::endl; + crip = playfair(crip, key); return 0; }