Author Topic: Random password generator!  (Read 1016 times)

0 Members and 1 Guest are viewing this topic.

Offline kenjoe41

  • Symphorophiliac Programmer
  • Administrator
  • Baron
  • *
  • Posts: 990
  • Cookies: 224
    • View Profile
Random password generator!
« on: 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.
Code: (c++) [Select]
// 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]
If you can't explain it to a 6 year old, you don't understand it yourself.
http://upload.alpha.evilzone.org/index.php?page=img&img=GwkGGneGR7Pl222zVGmNTjerkhkYNGtBuiYXkpyNv4ScOAWQu0-Y8[<NgGw/hsq]>EvbQrOrousk[/img]

Offline anotherman

  • NULL
  • Posts: 1
  • Cookies: 0
    • View Profile
Re: Random password generator!
« Reply #1 on: September 13, 2014, 07:08:41 am »
like a boss.


Code: (c) [Select]
//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;
}
« Last Edit: September 13, 2014, 07:10:11 am by anotherman »

Offline kenjoe41

  • Symphorophiliac Programmer
  • Administrator
  • Baron
  • *
  • Posts: 990
  • Cookies: 224
    • View Profile
Re: Random password generator!
« Reply #2 on: 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.
If you can't explain it to a 6 year old, you don't understand it yourself.
http://upload.alpha.evilzone.org/index.php?page=img&img=GwkGGneGR7Pl222zVGmNTjerkhkYNGtBuiYXkpyNv4ScOAWQu0-Y8[<NgGw/hsq]>EvbQrOrousk[/img]