Created
March 29, 2013 08:45
-
-
Save Battleroid/5269547 to your computer and use it in GitHub Desktop.
Used to make fake CD keys for Steam for shits and giggles.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <random> | |
#include <ctime> | |
#include <vector> | |
#include <fstream> | |
#include <string> | |
using namespace std; | |
int main () { | |
string content = "abcdefghijklmnopqrstuvwxyz0123456789"; | |
vector<string> codes; | |
srand(time(0)); | |
fstream output("codes.txt", ios::out); | |
cout << "Create how many?: "; | |
int amount; | |
cin >> amount; | |
// open file | |
if (output.is_open()) { | |
for (int i = 0; i < amount; i++) { | |
string code = ""; | |
for (int j = 0; j < 15; j++) { | |
if (j == 5 || j == 10) | |
code += "-"; | |
int randitem = rand() % content.length(); | |
code += toupper(content[randitem]); | |
} | |
// check for duplicates (sort of, whatever) | |
if (i == 0) { | |
codes.push_back(code); | |
cout << i + 1 << ":\t" << code << endl; | |
output << code << endl; | |
} else { | |
vector<string>::iterator it = find(codes.begin(), codes.end(), code); | |
if (it == codes.end()) { | |
codes.push_back(code); | |
cout << i + 1 << ":\t" << code << endl; | |
output << code << endl; | |
} else { | |
i--; | |
cout << "Duplicate found, retrying..." << endl; | |
} | |
} | |
} | |
output.close(); | |
return 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment