Advertisement
darkn3tc0d3r

Untitled

Dec 22nd, 2013
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.91 KB | None | 0 0
  1. //+ Decryption ...
  2. //+ source
  3.  
  4.  
  5. #include <iostream>
  6. #include <fstream>
  7. #include <cstdlib>
  8. using namespace std;
  9. const int kSTART = 0;
  10. const int kINCREMENT = 1;
  11. static int substitutions[] = {
  12. 'U', 'L', 'd', '{', 'p', 'Q', '@', 'M',
  13. '-', ']', 'O', 'r', 'c', '6', '^', '#',
  14. 'Y', 'w', 'W', 'v', '!', 'F', 'b', ')',
  15. '+', 'h', 'J', 'f', 'C', '8', 'B', '7',
  16. '.', 'k', '2', 'u', 'Z', '9', 'K', 'o',
  17. '3', 'x', ' ', '\'', '=', '&', 'N', '*',
  18. '1', 'z', '(', '`', 'R', 'P', ':', 'l',
  19. '4', '0', 'e', '$', '_', '}', 'j', 't',
  20. '?', 'S', 'q', '>', ';', 'T', 'y', 'i',
  21. '\\', 'A', 'D', 'V', '5', '|', '<', '/',
  22. 'E', 'g', 'm', ',', '[', 'H', '%', 'a',
  23. 's', 'n', 'I', 'X', '~', '"', 'G'
  24. };
  25. const int len = sizeof(substitutions) / sizeof(int);
  26. static int rtable[len];
  27. static ifstream infile;
  28. void MakeRTable(void);
  29. void Decrypt(void);
  30. void OpenInputfile(void);
  31. void SaveToFile(const char m[]);
  32. void OpenInputfile(void)
  33. {
  34. const int kNAMESIZE = 100;
  35. char filename[kNAMESIZE];
  36. cout <<"\t\t\t:] CODED BY XXLB::OREN [:"<<endl;
  37. cout << "\n\nName of file to decrypt :> " ;
  38. cin.getline(filename, kNAMESIZE-1, '\n');
  39. cout <<"\n\n--------------------------------------------------------------------------------"<<endl;
  40. infile.open(filename, ios::in);
  41. if(!infile.good()) {
  42. cout << "Can't open that file. Quitting." << endl;
  43. exit(1);
  44. }
  45. }
  46. void MakeRTable(void)
  47. {
  48. for(int i = 0;i < len; i++) {
  49. int tem = substitutions[i];
  50. tem -= ' ';
  51. rtable[tem] = i;
  52. }
  53. }
  54. void Decrypt(void)
  55. {
  56. int ch;
  57. int linepos = 0;
  58. int k = kSTART;
  59. ch = infile.get();
  60. while(ch != EOF) {
  61. int t = rtable[ch - 32];
  62. t -= k;
  63. while(t<0) t+= len;
  64. cout << char(t + ' ');
  65. if((t==0) && (linepos > 60))
  66. { cout << endl; linepos = 0; }
  67. k += kINCREMENT;
  68. ch = infile.get();
  69. }
  70. cout <<"\n\n--------------------------------------------------------------------------------"<<endl;
  71. }
  72. int main()
  73. {
  74. OpenInputfile();
  75. MakeRTable();
  76. Decrypt();
  77. system("pause");
  78. return 0;
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement