Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Generates valid registration keys for a game on the PocketPC
- #include<iostream>
- #include<ctime>
- const char gameId[] = {'D', 'A', 'T', 'A'};
- char to_char(char i) {
- if(i>=36) return 0;
- if(i<10) return char(i)+'0';
- return i-10+'A';
- }
- int main() {
- unsigned char ikeys[8];
- unsigned int a[6];
- unsigned int u1 = gameId[0] + gameId[1];
- unsigned int u2 = gameId[2] + gameId[3];
- srand(time(NULL));
- for(int i=0;i<8;++i)
- ikeys[i] = rand() % 0x24;
- a[0] = (ikeys[0] + ikeys[1] + ikeys[2] + ikeys[3]) % 0x24;
- a[1] = (ikeys[4] + ikeys[5] + ikeys[6] + ikeys[7]) % 0x24;
- a[2] = (ikeys[0] * ikeys[1] * ikeys[2] * ikeys[3]) % 0x24;
- a[3] = (ikeys[4] * ikeys[5] * ikeys[6] * ikeys[7]) % 0x24;
- a[4] = (a[0] * u1) % 0x24;
- a[5] = (a[1] * u2) % 0x24;
- char skeys[] = { to_char(ikeys[0]), to_char(ikeys[4]), to_char(a[2]),
- to_char(ikeys[1]), to_char(ikeys[5]), to_char(a[3]),
- to_char(ikeys[2]), to_char(ikeys[6]), to_char(a[4]),
- to_char(ikeys[3]), to_char(ikeys[7]), to_char(a[5]) };
- std::cout << "Random valid key: ";
- for(auto c: skeys) std::cout << c << " ";
- std::cout << '\n';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement