fixing gui
[mnenc] / mnenc.cpp
1 //      mnenc.cpp\r
2 //      \r
3 //      Copyright 2010 Micke Nordin <mickewiki@gmail.com>\r
4 //      \r
5 //      This program is free software; you can redistribute it and/or modify\r
6 //      it under the terms of the GNU General Public License as published by\r
7 //      the Free Software Foundation; either version 3 of the License, or\r
8 //      (at your option) any later version.\r
9 //      \r
10 //      This program is distributed in the hope that it will be useful,\r
11 //      but WITHOUT ANY WARRANTY; without even the implied warranty of\r
12 //      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
13 //      GNU General Public License for more details.\r
14 //      \r
15 //      You should have received a copy of the GNU General Public License\r
16 //      along with this program; if not, write to the Free Software\r
17 //      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,\r
18 //      MA 02110-1301, USA.\r
19 \r
20 \r
21 \r
22 #include <iostream>\r
23 #include <string>\r
24 #include <fstream>\r
25 #include <cstdlib>\r
26 #include <ctime>\r
27 #include "mnenc.hpp"\r
28 \r
29 mnenc::mnenc() {\r
30         key = "";\r
31 }\r
32 \r
33 void mnenc::genkey(std::string str) {\r
34         key = str + str + str + str + str + str + str + str + str;\r
35 }\r
36 \r
37 std::string mnenc::encrypt(std::string key, std::string str) {\r
38         for(int i=0; i < (signed) str.size(); i++)      {\r
39                 str[i]=str[i]^key[i];\r
40         }\r
41         return str;\r
42 }\r
43  \r
44 std::string mnenc::decrypt(std::string key, std::string passwd) {\r
45         for(int i=0; i < (signed) passwd.size(); i++)   {\r
46                 passwd[i] = key[i] ^ passwd[i];\r
47         }\r
48         return passwd;\r
49 }\r
50 std::string mnenc::get_key() {\r
51         if(key != "") {\r
52                 return key;\r
53         } else {\r
54                 std::cerr << "Error: No key generated.";\r
55                 return key;\r
56         }\r
57 }\r
58 \r
59 \r
60 \r
61 \r
62 \r
63 \r
64 \r
65 \r