Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old October 16th, 2002, 03:24 AM
peter83 peter83 is offline
Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 19 peter83 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
auto generate password

how to i generate a password that contains 11 chars including alphabets (Uppercase and lowercase) and numbers. However, there should not be "one", "o", "zero", "uppercase i" and "lowercase L" in the password .

pls help asap..
thanks..

Reply With Quote
  #2  
Old October 16th, 2002, 12:19 PM
noslenj123 noslenj123 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Location: Phoenix, AZ
Posts: 482 noslenj123 User rank is Sergeant Major (2000 - 5000 Reputation Level)noslenj123 User rank is Sergeant Major (2000 - 5000 Reputation Level)noslenj123 User rank is Sergeant Major (2000 - 5000 Reputation Level)noslenj123 User rank is Sergeant Major (2000 - 5000 Reputation Level)noslenj123 User rank is Sergeant Major (2000 - 5000 Reputation Level)noslenj123 User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 21 h 34 m 11 sec
Reputation Power: 30
Quote:
how do i generate a password that contains 11 chars including alphabets (Uppercase and lowercase) and numbers.
Well, I'm experienced in several other languages but I'm a newbie to Java. However I'm sure Java has a random() function of some kind that you could use. The following psuedo code could give you what you want:
PHP Code:
 validChars 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
for ( 
i=1i<12i++ ) {
    
password password validChars[random(validChars.length())];

Quote:
However, there should not be "one", "o", "zero", "uppercase i" and "lowercase L" in the password .
Not sure what you mean here.....

Reply With Quote
  #3  
Old October 16th, 2002, 07:29 PM
peter83 peter83 is offline
Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 19 peter83 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
well, your method doesn't work..
any other ways??

Reply With Quote
  #4  
Old October 16th, 2002, 11:04 PM
bricker42 bricker42 is offline
Moderator =(8^(|)
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Feb 2002
Location: Sacramento, CA
Posts: 1,710 bricker42 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 38 sec
Reputation Power: 8
Send a message via AIM to bricker42
Make
Code:
validChars[random(validChars.length())];

into
Code:
String.valueOf( validChars.charAt( Math.random() * validChars.length ) )

Last edited by bricker42 : October 16th, 2002 at 11:07 PM.

Reply With Quote
  #5  
Old October 16th, 2002, 11:20 PM
peter83 peter83 is offline
Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 19 peter83 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
hi,

i tried the method but i got this error:

"Attempt to reference method length in class java.lang.String as an instance variable."




Reply With Quote
  #6  
Old October 17th, 2002, 12:03 AM
bricker42 bricker42 is offline
Moderator =(8^(|)
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Feb 2002
Location: Sacramento, CA
Posts: 1,710 bricker42 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 38 sec
Reputation Power: 8
Send a message via AIM to bricker42
Sorry, it should be validChars.length()

Reply With Quote
  #7  
Old October 17th, 2002, 07:25 PM
peter83 peter83 is offline
Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 19 peter83 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
now i get this error..

Quote:
Incompatible type for method. Explicit cast needed to convert double to int.


how do i solve it.???

Pls reply asap.. this is very important..

Reply With Quote
  #8  
Old October 17th, 2002, 09:15 PM
noslenj123 noslenj123 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Location: Phoenix, AZ
Posts: 482 noslenj123 User rank is Sergeant Major (2000 - 5000 Reputation Level)noslenj123 User rank is Sergeant Major (2000 - 5000 Reputation Level)noslenj123 User rank is Sergeant Major (2000 - 5000 Reputation Level)noslenj123 User rank is Sergeant Major (2000 - 5000 Reputation Level)noslenj123 User rank is Sergeant Major (2000 - 5000 Reputation Level)noslenj123 User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 21 h 34 m 11 sec
Reputation Power: 30
Ya see bricker42, this is why it's better to post psuedo code. Some characters simply want you to do their work FOR them. There is no indication that he has even tried. I'm done!

Reply With Quote
  #9  
Old October 17th, 2002, 09:27 PM
peter83 peter83 is offline
Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 19 peter83 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
hey man... i did tried ok...
it just doesn't work...
can you not accuse others of things they did not do...

Reply With Quote
  #10  
Old October 18th, 2002, 03:28 PM
noslenj123 noslenj123 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Location: Phoenix, AZ
Posts: 482 noslenj123 User rank is Sergeant Major (2000 - 5000 Reputation Level)noslenj123 User rank is Sergeant Major (2000 - 5000 Reputation Level)noslenj123 User rank is Sergeant Major (2000 - 5000 Reputation Level)noslenj123 User rank is Sergeant Major (2000 - 5000 Reputation Level)noslenj123 User rank is Sergeant Major (2000 - 5000 Reputation Level)noslenj123 User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 21 h 34 m 11 sec
Reputation Power: 30
Quote:
hey man... i did tried ok...
Sorry to offend you. I looked through the posts and see no indication you tried. Generally you would post what you did try.
Quote:
it just doesn't work...
So we really don't know what it is that didn't work.
Quote:
can you not accuse others of things they did not do...
Then show us what you did.

Actually, even though I have only been looking at Java for a couple of weeks, I decided to turn the psuedo-code I gave into Java code. It took me about 15 minutes and I had the code working just fine. First run gave me 'w0z7k2TRowc', the second '7FvR7nk2ivk'.

Did you search a manual or book for "Random"? Otherwise known as RTFM. Better yet, did you search the internet for it? I did, and I didn't bug anybody to do it for me.
Quote:
Pls reply asap.. this is very important..
<soapbox>This is what bugs people. It's very important to who? You. And you only. No one needs to help you ASAP! They have better things to do. Like help people that are humble and appreciate it.</soapbox>

Good luck!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > auto generate password


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway