Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <iterator>
- #include <vector>
- #include <algorithm>
- using namespace std;
- struct cell
- {
- unsigned char operationCode;
- unsigned char operationParameter;
- unsigned int legnthToOperateOn;
- } typedef cell;
- int main()
- {
- ifstream msg;
- cell cur, cur2, cur3;
- int i;
- int flag = 0;
- int rev = 0;
- msg.open("EncryptedMessage.bin", ios::binary);
- vector<unsigned char> vec((std::istreambuf_iterator<char>(msg)), std::istreambuf_iterator<char>());
- vector<unsigned char> vecCpy = vec;
- vector<unsigned char>::iterator it = vec.begin();
- int vecLen = vec.size();
- for (int a = 0; a < 3; a++)
- for (int b = 0; b < 256; b++)
- for (int c = 0; c < vecLen; c++)
- {
- cur.operationCode = a;
- cur.operationParameter = b;
- cur.legnthToOperateOn = c;
- for (int j = 0; j < cur.legnthToOperateOn; j++)
- {
- switch (cur.operationCode)
- {
- case 0:
- *it ^= cur.operationParameter;
- break;
- case 1:
- *it += cur.operationParameter;
- break;
- case 2:
- *it -= cur.operationParameter;
- break;
- }
- //rev == 1 ? it-- : it++;
- if (rev == 1)
- it--;
- else if (rev == 0)
- it++;
- if (it == vec.end())
- {
- rev = 1;
- it--;
- }
- else if (it == vec.begin())
- rev = 0;
- }
- for (std::vector<unsigned char>::const_iterator i = vec.begin(); i != vec.end(); ++i)
- {
- if (*i < 32 || (*i > 32 && *i < 63) || *i == 64 || (*i > 90 && *i < 97) || *i > 122)
- flag = 1;
- else
- cout << *i;
- }
- cout << "\n\n";
- if (flag != 1)
- {
- cout << "FOUND!\n\n";
- for (std::vector<unsigned char>::const_iterator i = vec.begin(); i != vec.end(); ++i)
- std::cout << *i;
- }
- flag = 0;
- vec = vecCpy;
- it = vec.begin();
- }
- //for (std::vector<unsigned char>::const_iterator i = vec.begin(); i != vec.end(); ++i)
- //std::cout << *i;
- msg.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement