|
@@ -0,0 +1,39 @@
|
|
1
|
+#include <iostream>
|
|
2
|
+#include <string>
|
|
3
|
+#include "include/Crypt.h"
|
|
4
|
+#include "include/Test.h"
|
|
5
|
+
|
|
6
|
+char START = START;
|
|
7
|
+char END = END;
|
|
8
|
+
|
|
9
|
+/**
|
|
10
|
+ @brief Take a string on command line argument to encrypt it. For vigenere encnyption, the text is encrypted with itself as a key
|
|
11
|
+ **/
|
|
12
|
+int main( int argc, char* argv[] )
|
|
13
|
+{
|
|
14
|
+ std::string txt = argv[1] ;
|
|
15
|
+
|
|
16
|
+ if( argc < 1 ){
|
|
17
|
+ std::cout << "Missing argument : need sentance to encrypt" << std::endl;
|
|
18
|
+ return 0;
|
|
19
|
+ }
|
|
20
|
+ if( argc > 1 ){
|
|
21
|
+ START = argv[2][0] ;
|
|
22
|
+ }
|
|
23
|
+ if( argc > 2 ){
|
|
24
|
+ END = argv[3][0] ;
|
|
25
|
+ }
|
|
26
|
+
|
|
27
|
+ std::string test_1 = "la mer à boire" ;
|
|
28
|
+ std::string test_2 = "xyzabc" ;
|
|
29
|
+
|
|
30
|
+ Test::assertEqual( Crypt::cesar( test_1, 3, START, END ), "od phu à erluh") ;
|
|
31
|
+ Test::assertEqual( Crypt::vigenere( test_1, test_1, START, END ), "xb zjj à ddrjj") ;
|
|
32
|
+ Test::assertEqual( Crypt::atbash( test_1, START, END ), "oz nvi à ylriv") ;
|
|
33
|
+
|
|
34
|
+ Test::assertEqual( Crypt::cesar( test_2, 3, START, END ), "abcdef") ;
|
|
35
|
+ Test::assertEqual( Crypt::vigenere( test_2, test_1, START, END ), "jzzngu") ;
|
|
36
|
+ Test::assertEqual( Crypt::atbash( test_2, START, END ), "cbazyx") ;
|
|
37
|
+
|
|
38
|
+ return 0;
|
|
39
|
+}
|