Browse Source

Makefile and mains

nas 2 years ago
parent
commit
956cbb079b
2 changed files with 27 additions and 6 deletions
  1. 9
    1
      Makefile
  2. 18
    5
      main.cpp

+ 9
- 1
Makefile View File

@@ -1,6 +1,6 @@
1 1
 CC=g++
2 2
 LDFLAGS=
3
-CFLAGS=-Wall -Wextra -O -std=c++17
3
+CFLAGS=-Wall -Wextra -O -std=c++17 -lboost_program_options
4 4
 
5 5
 STATE=debug
6 6
 
@@ -22,10 +22,18 @@ crypt: $(OBJ)main.o $(OBJ)Crypt.o
22 22
 	@echo "\nCompilation de \033[0;36m $@ \033[0m"
23 23
 	$(CC) -o $(BIN)$@ $^ $(LDFLAGS)
24 24
 
25
+debug: $(OBJ)main_debug.o $(OBJ)Crypt.o $(OBJ)Test.o  
26
+	@echo "\nCompilation de \033[0;36m $@ \033[0m"
27
+	$(CC) -o $(BIN)$@ $^ $(LDFLAGS)
28
+
25 29
 $(OBJ)main.o: main.cpp
26 30
 	@echo "\nCompilation de \033[0;36m $@ \033[0m"
27 31
 	$(CC) -o $@ -c $^ $(CFLAGS)
28 32
 
33
+$(OBJ)main_debug.o: main_debug.cpp
34
+	@echo "\nCompilation de \033[0;36m $@ \033[0m"
35
+	$(CC) -o $@ -c $^ $(CFLAGS)
36
+
29 37
 $(OBJ)%.o: $(SRC)%.cpp $(INCLUDE)%.h
30 38
 	@echo "\nCompilation de \033[0;36m $@ \033[0m"
31 39
 	@$(CC) -o $@ -c $< $(CFLAGS)

+ 18
- 5
main.cpp View File

@@ -1,8 +1,9 @@
1 1
 #include <iostream>
2
+#include <string>
2 3
 #include "include/Crypt.h"
3 4
 
4
-const char START = 'a';
5
-const char END = 'z';
5
+char START = 'a';
6
+char END = 'z';
6 7
 
7 8
 /**
8 9
  @brief Take a string on command line argument to encrypt it. For vigenere encnyption, the text is encrypted with itself as a key
@@ -10,10 +11,22 @@ const char END = 'z';
10 11
 int main( int argc, char* argv[]  )
11 12
 {
12 13
   std::string txt = argv[1] ;
14
+  
15
+  if( argc < 1 ){
16
+    std::cout << "Missing argument : need sentance to encrypt" << std::endl;
17
+    return 0;
18
+  }
19
+  if( argc > 1 ){
20
+    START = argv[2][0] ;
21
+  }
22
+  if( argc > 2 ){
23
+    END = argv[3][0] ;
24
+  }
25
+  std::cout << "start, end :" << START << " " << END << std::endl;
13 26
   std::cout << "to encrypt :" << txt << std::endl;
14
-  std::cout << "code cesar :" <<  Crypt::cesar(txt, 3 ) << std::endl ;
15
-  std::cout << "code vigenere :" << Crypt::vigenere(txt, txt ) << std::endl ;
16
-  std::cout << "code atbash :" << Crypt::atbash( txt ) << std::endl ;
27
+  std::cout << "code cesar :" <<  Crypt::cesar(txt, 3, START, END ) << std::endl ;
28
+  std::cout << "code vigenere :" << Crypt::vigenere(txt, txt, START, END ) << std::endl ;
29
+  std::cout << "code atbash :" << Crypt::atbash( txt, START, END ) << std::endl ;
17 30
   
18 31
   return 0;
19 32
 }

Loading…
Cancel
Save