Page 1 of 1

Random Combination[help]

Posted: Sun Apr 20, 2008 8:41 pm
by WxNoob
Hi all !!

There was a long time that i didnĀ“t posted in this forum hehe, whats up?

Well, now i`m trying to make another programme, wich generates a random combination of numbers and letters...

I will explain what i want to do:

I have a Form, with a editbox, and a button.

Then, what i want is that if a click on that button, it will automatically generates a random combination of numbers and letters and it will show that combination into the editbox...

So, what i want to find now is a way to generate random combinations...

Can someone give me a little help? :P

Thanx a lot...!!

Re: Random Combination[help]

Posted: Mon Apr 21, 2008 8:21 am
by Deschamps
WxNoob wrote:Can someone give me a little help?
Have you tried something, yet? What problems have you encountered with your code?

As a suggestion, you could try generating each character (one after another), using their ASCII codes (with a previously defined interval for valid characters and numbers to generate), storing all the generated numbers and character into a string.

If you are looking for specific source code, there are thousand samples in the Internet using the random functions in C++.

Regards.

Posted: Mon Apr 21, 2008 9:48 am
by Jorg
Just to prevent you from reinventing the wheel. If you are making a password generator, KeePass Password Safe does a hell of a job generating 'x' bits ciphers.

Regards,
- Jorgen

Posted: Tue Apr 22, 2008 4:59 pm
by WxNoob
If you are making a password generator, KeePass Password Safe does a hell of a job generating 'x' bits ciphers.
Yes, I know there are lots of softwares round the Net that makes that more simply, but what I want is to make my own generator hehe ....

My idea is to create a software who will help people to have safer passwords, because a lot of people have passwords like "1234".....xD....so...it will help them to have safer passwords and avoid to be hacked hehe...

I will be very gratefull to recive more ansews :)

Posted: Wed Apr 23, 2008 6:23 am
by Jorg
You should then take a look at crypt libs that can generate cyphers for you. Although a typical random generator is already enough for home apps.

A Random generator is nothing more then a number between x and y. Usually they even do floating point or within a given range. What you should do (for ease of use) is define a character array like;

Code: Select all

wxString rndchars = "1234567890abcdefghijklmnopqrstuvw....";

wxString pwd;
for(int i = 0; i < YOUR_MAX_PWD_LEN; i++)
   pwd.Append( rndchars[rand() % rndchars.Len()]);

// pwd contains a randomized character set
// you might need to set srand() to seed first