Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //+ Decryption ...
- //+ source
- #include <iostream>
- #include <fstream>
- #include <cstdlib>
- using namespace std;
- const int kSTART = 0;
- const int kINCREMENT = 1;
- static int substitutions[] = {
- 'U', 'L', 'd', '{', 'p', 'Q', '@', 'M',
- '-', ']', 'O', 'r', 'c', '6', '^', '#',
- 'Y', 'w', 'W', 'v', '!', 'F', 'b', ')',
- '+', 'h', 'J', 'f', 'C', '8', 'B', '7',
- '.', 'k', '2', 'u', 'Z', '9', 'K', 'o',
- '3', 'x', ' ', '\'', '=', '&', 'N', '*',
- '1', 'z', '(', '`', 'R', 'P', ':', 'l',
- '4', '0', 'e', '$', '_', '}', 'j', 't',
- '?', 'S', 'q', '>', ';', 'T', 'y', 'i',
- '\\', 'A', 'D', 'V', '5', '|', '<', '/',
- 'E', 'g', 'm', ',', '[', 'H', '%', 'a',
- 's', 'n', 'I', 'X', '~', '"', 'G'
- };
- const int len = sizeof(substitutions) / sizeof(int);
- static int rtable[len];
- static ifstream infile;
- void MakeRTable(void);
- void Decrypt(void);
- void OpenInputfile(void);
- void SaveToFile(const char m[]);
- void OpenInputfile(void)
- {
- const int kNAMESIZE = 100;
- char filename[kNAMESIZE];
- cout <<"\t\t\t:] CODED BY XXLB::OREN [:"<<endl;
- cout << "\n\nName of file to decrypt :> " ;
- cin.getline(filename, kNAMESIZE-1, '\n');
- cout <<"\n\n--------------------------------------------------------------------------------"<<endl;
- infile.open(filename, ios::in);
- if(!infile.good()) {
- cout << "Can't open that file. Quitting." << endl;
- exit(1);
- }
- }
- void MakeRTable(void)
- {
- for(int i = 0;i < len; i++) {
- int tem = substitutions[i];
- tem -= ' ';
- rtable[tem] = i;
- }
- }
- void Decrypt(void)
- {
- int ch;
- int linepos = 0;
- int k = kSTART;
- ch = infile.get();
- while(ch != EOF) {
- int t = rtable[ch - 32];
- t -= k;
- while(t<0) t+= len;
- cout << char(t + ' ');
- if((t==0) && (linepos > 60))
- { cout << endl; linepos = 0; }
- k += kINCREMENT;
- ch = infile.get();
- }
- cout <<"\n\n--------------------------------------------------------------------------------"<<endl;
- }
- int main()
- {
- OpenInputfile();
- MakeRTable();
- Decrypt();
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement