The correct key will decrypt some fixed ciphertext into fixed plaintext. The known plaintext is apparently the digits of pi as hex digits.
Code:
#include <iostream>
#include <sstream>
#include <stdint.h>
int main(int argc, char* argv[])
{
if (argc != 2) {
std::cout << "Usage: " << argv[0] << " <key>" << std::endl;
return 0;
}
uint64_t k;
std::stringstream ss;
ss << argv[1];
ss >> std::hex >> k;
if (!ss) {
std::cout << "Invalid key!" << std::endl;
return 0;
}
uint32_t s = 0;
for (int i = 0; i < 10000; ++i) {
s = s * 1664525 + 1013904223;
int j = s % 64;
uint64_t a = (k >> j) & 1;
uint64_t b = (k & 1) << j;
k ^= a ^ b;
}
uint64_t r = k ^ 0x1221777f1c3e4341;
if (r == 0x3141592653589793) {
std::cout << "Correct key!" << std::endl;
} else {
std::cout << "Wrong key!" << std::endl;
}
return 0;
}