No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

main_debug.cpp 1.1KB

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