From 2be06c8f7e58a670057d13b36df28caa3f33f7b6 Mon Sep 17 00:00:00 2001 From: Marcela Ribeiro de Oliveira <mro15@inf.ufpr.br> Date: Wed, 25 Apr 2018 15:52:32 -0300 Subject: [PATCH] lol --- include/playfair.h | 2 ++ playfair.cpp | 12 ------------ playunfair.cpp | 16 ++++++++++------ 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/include/playfair.h b/include/playfair.h index 51675d4..f2de87b 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 3bed308..87e18fa 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 7ca0f88..73f3750 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; } -- GitLab