EvilZone

Programming and Scripting => C - C++ => : kenjoe41 September 06, 2014, 09:45:29 PM

: Random password generator!
: kenjoe41 September 06, 2014, 09:45:29 PM
This is my random password generator. It relies on the boost's random_device for entropy that it feeds to uniform_int_distribution. It is a variant of non-deterministic random number generation.
: (c++)
// Random_password.cpp
/*
    This code generates a random character password of length as specified on commandline.
    Else it generates upto 8 characters.
    Using a model for a non-deterministic random number generator.
 */

//Boost random lib
#include <boost/random/random_device.hpp>//for entropy
#include <boost/random/uniform_int_distribution.hpp>

#include <cstdlib>
#include <iostream>
using namespace std;

int main(int argc, char* argv[]) {

    if(argc = 2){
        //cout << "Usage: random_pass 10\n"<<endl;
        auto length = atoi(argv[1]);
    }else{
        auto length = 8;
    }
    string chars(//Chars we are going to allow. Normal keyboard characters
        "abcdefghijklmnopqrstuvwxyz"
        "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
        "1234567890"
        "!@#$%^&*()"
        "`~-_=+[{]{\\|;:'\",<.>/? ");
    //random_device is for entropy, for a non-predictable password.
    boost::random::random_device rng;
    //Now generate random characters of specified length of charaters from our chars string.
    boost::random::uniform_int_distribution<> index_dist(0, chars.size() - 1);//returns a random integer on each invocation froma set of integers

    for(int i = 0; i < length; ++i) {
        cout << chars[index_dist(rng)];
    }
    cout << endl;
}
[code]
: Re: Random password generator!
: anotherman September 13, 2014, 07:08:41 AM
like a boss.


: (c)
//private, don't share; random string generator.
void main( )
{
   cout << "What letter are you thinking of? ";
   getline(cin, input);
   cout << "Your random letter is: " << input;
}
: Re: Random password generator!
: kenjoe41 September 16, 2014, 03:46:06 PM
What are the chances i get to hit the same letters another time.
Crackers like WordHound might be able to brute force your password with a slight search of what you are familiar with.