Random Combination[help]

If you are using wxDev-C++ for your wxWidgets design, please ask your questions here instead of in IDE Related.
Post Reply
WxNoob
Earned a small fee
Earned a small fee
Posts: 15
Joined: Mon Jan 28, 2008 7:03 pm

Random Combination[help]

Post by WxNoob » Sun Apr 20, 2008 8:41 pm

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...!!

Deschamps
Knows some wx things
Knows some wx things
Posts: 30
Joined: Tue May 01, 2007 12:16 pm

Re: Random Combination[help]

Post by Deschamps » Mon Apr 21, 2008 8:21 am

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.
Misquotations are the only quotations that are never misquoted

Jorg
Moderator
Moderator
Posts: 3971
Joined: Fri Aug 27, 2004 9:38 pm
Location: Delft, Netherlands
Contact:

Post by Jorg » Mon Apr 21, 2008 9:48 am

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
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb

WxNoob
Earned a small fee
Earned a small fee
Posts: 15
Joined: Mon Jan 28, 2008 7:03 pm

Post by WxNoob » Tue Apr 22, 2008 4:59 pm

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 :)

Jorg
Moderator
Moderator
Posts: 3971
Joined: Fri Aug 27, 2004 9:38 pm
Location: Delft, Netherlands
Contact:

Post by Jorg » Wed Apr 23, 2008 6:23 am

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

Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb

Post Reply