#include <iostream>
#include <string>
#include <vector>
std::string xorEncryptDecrypt(const std::string& input, char key) {
std::string result = input;
for (size_t i = 0; i < input.length(); ++i)
result[i] ^= key;
return result;
}
int calculateChecksum(const std::string& input) {
int checksum = 0;
for (char c : input)
checksum += static_cast<unsigned char>(c);
return checksum;
}
void generatePasswords() {
const size_t passLength = 8;
const int targetChecksum = 300;
std::vector<char> password(passLength, 'A');
while (true) {
std::string passwordStr(password.begin(), password.end());
if (calculateChecksum(xorEncryptDecrypt(xorEncryptDecrypt(xorEncryptDecrypt(passwordStr, 75), 76), 77)) == targetChecksum)
std::cout << "Valid password: " << passwordStr << std::endl;
int i = passLength - 1;
while (i >= 0 && password[i] == 126)
password[i--] = 32;
if (i < 0)
break;
password[i]++;
}
}
int main() {
generatePasswords();
return 0;
}