Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <shlwapi.h>
- #include <string>
- #pragma comment( lib, "shlwapi.lib")
- using namespace std;
- int main(int argc, char* argv[])
- {
- ifstream keyFile("key.dat", ios_base::binary);
- string header = "";
- string key = "";
- if(!keyFile.is_open())
- return 0;
- getline(keyFile, header);
- getline(keyFile, key);
- keyFile.close();
- char keyDat[18];
- sprintf_s(keyDat, 18, "%s", key.c_str());
- printf("Please input your plain-text key. DO NOT use dashes in this key. Make sure it is one word.\n");
- char keyRaw[18];
- gets_s(keyRaw, 18);
- char keyDigest[18];
- for(int i = 0; i < 18; i++)
- {
- keyDigest[i] = (char) keyDat[i] ^ keyRaw[i];
- }
- ifstream lostKeyFile("keyLost.dat", ios_base::binary);
- getline(lostKeyFile, header);
- key = "";
- getline(lostKeyFile, key);
- sprintf_s(keyDat, 18, "%s", key.c_str());
- memset(keyRaw, 0x00, 18);
- for(int i = 0; i < 18; i++)
- {
- keyRaw[i] = (char) keyDat[i] ^ keyDigest[i];
- }
- printf("Your recovered key is: %s\n", keyRaw);
- keyFile.close();
- printf("Press Enter to save this key to out.txt and close the program.");
- cin.ignore();
- ofstream outFile("out.txt");
- outFile.write(keyRaw, 17);
- outFile.close();
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement