1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>
#include <cstdio>
static const char alphanum[3][26] = {
{'0','1', '2','3','4','5','6','7','8','9'},
{'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'},
{'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'}
};
void alphaGen(){
for(int i = 0; i < 31; i++){
int num1 = (rand() % 3);
int num2 = (rand() % 27) - 1;
if(num1 < 0 || num1 > 27){
if(num1 < 0){
num1++;
} else if(num1 > 27){
num1--;
}
} if(num2 < 0 || num2 > 27){
if( num2 < 0){
num2++;
} else if(num2 > 27){
num2--;
}
}
int *generatedRandomNum1 = new int;
generatedRandomNum1 = &num1;
int *generatedRandomNum2 = new int;
generatedRandomNum2 = &num2;
}
}
void keygen(int sum){
alphaGen();
char Key[sum];
for(int c = 0; c < sum; c++){
Key[c] = alphanum[generatedRandomNum1][generatedRandomNum2];
} std::cout << Key[sum] << std::endl;
}
int main(int argc, const char *argv[]){
keygen(10);
}
| |