WPA2 20 char. keygenerate in C++

Hello guys, im new here and i had one question. Im trying to write c++ code that generates 20 character keys (used for WPA2) between 0 and 99999999999999999999. every key must be in 20 character format. what i have is this:

#include <iostream>
using namespace std;

int main(){

// ouputs are like this: 00000000023487643210

for ( int i = 0; i<= 99999999999999999999ULL; i ++){

if(i < 10)
cout << "0000000000000000000"<< i <<endl;

if (i >= 10 && i<100)
cout << "000000000000000000"<< i <<endl;

if (i >=100 && i<1000)
cout <<"00000000000000000"<< i << endl;

if( i >=1000 && i < 10000)
cout <<"0000000000000000"<< i<<endl;

if ( i >= 10000 && i< 100000)
cout << "000000000000000"<< i <<endl;

if ( i >= 100000 && i < 1000000)
cout << "00000000000000"<< i <<endl;

if ( i>= 1000000 && i < 10000000)
cout <<"0000000000000" << i <<endl;

if ( i>= 10000000 && i <100000000)
cout << "000000000000" << i <<endl;

if ( i >= 100000000 && i < 1000000000)
cout << "00000000000"<< i <<endl;

if ( i>= 1000000000 && i < 1000000000 )
cout << "0000000000"<<i<<endl;

if ( i>=10000000000 && i<100000000000)
cout << "000000000"<< i <<endl;

if (i>= 100000000000 && i <1000000000000)
cout << "00000000"<< i <<endl;

if (i>= 1000000000000 && i<10000000000000)
cout << "0000000"<< i <<endl;

if ( i >= 10000000000000 && i < 100000000000000)
cout << "000000" <<i <<endl;

if( i>= 100000000000000 && i<1000000000000000)
cout << "00000" << i<<endl;

if ( i>= 1000000000000000 && i < 10000000000000000)
cout << " 0000" << i <<endl;

if (i>= 10000000000000000 && i< 100000000000000000)
cout << "000"<<i<<endl;

if (i >= 100000000000000000 && i < 1000000000000000000)
cout << "00"<< i<<endl;

if( i>= 100000000000000000ULL && i<10000000000000000000ULL)
cout << "0"<< i<<endl;

//if (i>= 10000000000000000000 && i <100000000000000000000)
cout << i<<endl;

}

return 0;
}

So is there any better ways to solve this problem, without typing it manually with if and cout so much? Also in this code there are problems like 99999999999999999999ULL greater than defined integer, even with ULL. And therefore , how to fix the last commented statement, g++ and netbeans couldnt run it because its too large.

P.s: the code should only generate numbers, no ASCI signs

thanks.
Last edited on
Last edited on
Topic archived. No new replies allowed.