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;
- int i;
- 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>::iterator it = vec.begin();
- for (i = 0; i < 3; i++)
- {
- for (int a = 0; a < 3; a++)
- {
- for (int b = 0; b < 256; b++)
- {
- for (int c = 0; c < 1000; c++)
- {
- cur.operationCode = a;
- cur.operationParameter = b;
- cur.legnthToOperateOn = c;
- if (int(cur.operationCode) == 0)
- {
- for (int j = 0; j < cur.legnthToOperateOn; j++)
- {
- *it ^= int(cur.operationParameter);
- if (rev == 1)
- it--;
- else if (rev == 0)
- it++;
- if (it == vec.end())
- {
- rev = 1;
- it--;
- }
- else if (it == vec.begin())
- rev = 0;
- }
- }
- else if (int(cur.operationCode) == 1)
- {
- for (int j = 0; j < cur.legnthToOperateOn; j++)
- {
- *it += int(cur.operationParameter);
- if (rev == 1)
- it--;
- else if (rev == 0)
- it++;
- if (it == vec.end())
- {
- rev = 1;
- it--;
- }
- else if (it == vec.begin())
- rev = 0;
- }
- }
- else if (int(cur.operationCode) == 2)
- {
- for (int j = 0; j < cur.legnthToOperateOn; j++)
- {
- *it -= int(cur.operationParameter);
- 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)
- std::cout << *i;
- msg.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement