-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProtectUnprotect.cpp
42 lines (38 loc) · 1.22 KB
/
ProtectUnprotect.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <Windows.h>
#include <iostream>
#include <vector>
#pragma comment (lib, "Crypt32.lib")
void PrintDataBlob(DATA_BLOB DataToPrint) {
std::cout << "DATA BLOB SIZE : " << DataToPrint.cbData << "\n";
std::cout << "DATA BLOB {{{{";
for (int x = 0; x < DataToPrint.cbData; x++) {
std::cout << DataToPrint.pbData[x];;
}
std::cout << "}}}}\n";
}
DATA_BLOB CryptProtect(std::string ToEncrypt) {
DATA_BLOB EncryptedIn;
EncryptedIn.cbData = ToEncrypt.size();
EncryptedIn.pbData = new BYTE[ToEncrypt.size()];
memcpy(EncryptedIn.pbData, ToEncrypt.c_str(), ToEncrypt.size());
DATA_BLOB EncryptedOut;
EncryptedOut.cbData = 100;
EncryptedOut.pbData = 0;
CryptProtectData(&EncryptedIn, NULL, NULL, NULL, NULL, NULL, &EncryptedOut);
return EncryptedOut;
}
DATA_BLOB CryptUnprotect(DATA_BLOB ToDecrypt) {
DATA_BLOB DecryptedOut;
DecryptedOut.cbData = 100;
DecryptedOut.pbData = 0;
CryptUnprotectData(&ToDecrypt, NULL, NULL, NULL, NULL, NULL, &DecryptedOut);
return DecryptedOut;
}
// DATA IS IN FORM OF DATA_BLOB CUS THATS RAW
int main() {
DATA_BLOB EncryptedData = CryptProtect("testing lol21");
PrintDataBlob(EncryptedData);
DATA_BLOB DecryptedData = CryptUnprotect(EncryptedData);
PrintDataBlob(DecryptedData);
return 69;
}