Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Password Generator [Version 2]
#8
(11-07-2009, 12:26 PM)Project Evolution Wrote: Done version 2 I guess, trying to figure out character randomization, and for now im using the Random API for randomizing the numbers.

Think about it... what's a simple way of having numbers correspond to any element? If you guessed array, you're right.

You could set up an array of 26 characters, and then initialize them with a for loop. shouldn't take more than three lines of code.

Code:
char letters[26];
for(int i = 0; i < 26; i++) {
     letter[i] =(char) i + 97; //ascii key codes, 'a' is 97.
}

the iffy part here is the type-casting, I think java allows casting from an int to a char (I mean, why wouldn't they), but if not, I'm sure there's a method for turning an int into a char.

from there, you can get random characters by using pseudorandom elements in the array.

i.e...
Code:
char nextChar = letters[Random_generator.nextInt(25)]; //probably wrong syntax, but you know what I mean...
password.append(letter);
Reply


Messages In This Thread
RE: Password Generator - by ßeowulf - 11-07-2009, 09:24 AM
RE: Password Generator - by Project Evolution - 11-07-2009, 09:41 AM
RE: Password Generator - by ßeowulf - 11-07-2009, 10:16 AM
RE: Password Generator [Version 2] - by wat - 11-14-2009, 11:02 AM
RE: Password Generator [Version 2] - by ßeowulf - 11-07-2009, 03:20 PM
RE: Password Generator [Version 2] - by Ⱳąŗɗ - 03-13-2010, 10:45 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Java] Password Generator Version 3.0 CometJack 29 4,432 01-03-2012, 06:03 PM
Last Post: MineCrack
  Another Completly Nessacary Password Generator :D nevets04 10 1,947 05-03-2010, 01:50 AM
Last Post: JesusOfSuburbia
  My fith program: Password Generator nevets04 4 1,122 12-01-2009, 02:02 PM
Last Post: Project Evolution

Forum Jump:


Users browsing this thread: 1 Guest(s)