fork(1) download
  1. #include <stdio.h>
  2. #include <iostream>
  3. #include <iomanip>
  4.  
  5. using namespace std;
  6.  
  7. void encrypt_stand_message();
  8. const char key[] ="ALCtALC sixth headed civic outlying mayflower irregular boneless prevail freebase delirious projector dreamless";
  9.  
  10. int main ()
  11. {
  12. cout << "Plese choose option?\n\n";
  13. cout << "1. Cipher text\n\n";
  14. cout << "\n";
  15.  
  16. int option = 0;
  17. cin >> option;
  18. cin.ignore();
  19.  
  20. switch (option){
  21. case 1:
  22. encrypt_stand_message();
  23. encrypt_stand_message();
  24. exit(1);
  25. }
  26. }
  27.  
  28. void encrypt_stand_message(){
  29.  
  30. int x = 0, y = 0;
  31. char cipher;
  32. char message[300];
  33.  
  34. //system("clear");
  35.  
  36. cout << "Please enter the code to encrypt?\n\n";
  37.  
  38. cin.get(message, sizeof(message));
  39. cin.ignore();
  40.  
  41. cout << message << "\n";
  42.  
  43. char a = message[x];
  44. char b = key[y];
  45.  
  46. while (a != '\0'){
  47.  
  48. cipher = a ^ b;
  49.  
  50. //cout << cipher;
  51. cout << "'" << cipher << "' = " << hex << showbase << setw(2) << setfill('0') << (int)cipher << "\n";
  52.  
  53. x += 1;
  54. y += 1;
  55.  
  56. a = message[x];
  57.  
  58. if (key[y] == '\0'){
  59. y = 0;
  60. }
  61.  
  62. b = key[y];
  63. }
  64. }
Runtime error #stdin #stdout 0.01s 5368KB
stdin
1
alerte this is an amergency
rue rue mama mia
stdout
Plese choose option?

1. Cipher text


Please enter the code to encrypt?

alerte this is an amergency
' ' = 0x20
' ' = 0x20
'&' = 0x26
'' = 0x6
'5' = 0x35
')' = 0x29
'c' = 0x63
'T' = 0x54
'' = 0x1b
'' = 00
'' = 0xb
'T' = 0x54
'' = 0x1
'S' = 0x53
'H' = 0x48
'' = 0x4
'' = 0xf
'D' = 0x44
'' = 0x4
'	' = 0x9
'E' = 0x45
'' = 0x11
'' = 0xe
'' = 0x13
'' = 0x7
'' = 00
'Y' = 0x59
Please enter the code to encrypt?

rue rue mama mia
'3' = 0x33
'9' = 0x39
'&' = 0x26
'T' = 0x54
'3' = 0x33
'9' = 0x39
'&' = 0x26
'' = 00
'' = 0x1e
'' = 0x8
'' = 0x15
'' = 0x15
'H' = 0x48
'M' = 0x4d
'' = 0x1
'' = 0x4