Forums.Sureshkumar.net : A Perfect Place to Share Knowledge         Blogs     Games    Magazines    

"Sharing knowledge does not lessen your store, often it gets you more. Sharing plays a key role in relationships and bonding, happens in small steps and is assisted through community membership."

Go Back   SURESHKUMAR.NET FORUMS > TECHNICAL DISCUSSIONS > JAVA Technologies
Register FAQ Members List Calendar Games Blogs Search Today's Posts Mark Forums Read

   

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
Old 19-09-06, 02:46 PM   #1 (permalink)
Unregistered
Unregistered
 
Posts: n/a
Thumbs up how can i create the 7 digit AlfaNumeric Password .

hi friends
I want to know How can i Create the 7 digit AlfaNumeric Password which
will be unique for every user?
Plz give me Answer
my id is Singh_dharmendra2001@Yahoo.co.in.
 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following User Says Thank You to For This Useful Post:
Dharmendra Singh (21-09-06)
Old 19-09-06, 04:04 PM   #2 (permalink)
Moderator
 
t_mohan's Avatar
 
Join Date: Apr 2006
Location: India
Posts: 636
Thanks: 57
Thanked 78 Times in 63 Posts
Thanks: 57
Thanked 78 Times in 63 Posts
Rep Power: 17 t_mohan is a splendid one to behold t_mohan is a splendid one to behold t_mohan is a splendid one to behold t_mohan is a splendid one to behold t_mohan is a splendid one to behold t_mohan is a splendid one to behold t_mohan is a splendid one to behold
Re: how can i create the 7 digit AlfaNumeric Password .

Hi Dharmendhra,

Probably this could help you , i wrote a program which generates a password randomly, but it generates only numeric password. pls try to enhance it which meets your requirements

import java.util.Date;
import java.util.Random;

public class PasswordGenerator {
private Random rng = null;

public PasswordGenerator(){
rng = new Random((new Date()).getTime());
}

public String generatePassword() {
StringBuffer buff = new StringBuffer();
while (buff.length() < 8) {

buff.append(Math.abs(rng.nextInt()));
}

return buff.substring(0, 7);
}
public static void main(String args[])
{
PasswordGenerator pg = new PasswordGenerator();
System.out.println("Generated Password:"+pg.generatePassword());
}
}

It is a compiled code and executing fine

If u need any help, post a reply again

Thanks
Mohan.T
__________________
M0h@n
t_mohan is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following User Says Thank You to t_mohan For This Useful Post:
Dharmendra Singh (21-09-06)
Old 19-09-06, 06:22 PM   #3 (permalink)
Moderator
 
t_mohan's Avatar
 
Join Date: Apr 2006
Location: India
Posts: 636
Thanks: 57
Thanked 78 Times in 63 Posts
Thanks: 57
Thanked 78 Times in 63 Posts
Rep Power: 17 t_mohan is a splendid one to behold t_mohan is a splendid one to behold t_mohan is a splendid one to behold t_mohan is a splendid one to behold t_mohan is a splendid one to behold t_mohan is a splendid one to behold t_mohan is a splendid one to behold
Re: how can i create the 7 digit AlfaNumeric Password .

Hi Dharmendra

This is the code, which generates Random Password with alpha-numeric characters

Please feel free to ask me if you have any questions

import java.util.Date;
import java.util.Random;
import java.security.SecureRandom;

public class PasswordGenerator {
protected SecureRandom rand;
protected char[] firstAlphabet;
protected char[] lastAlphabet;
protected char[] alphabet;
public PasswordGenerator(){
rand = new SecureRandom();
}
public String generatePassword(char[] printableAlphabets) {
String generatedPassword = new String(getPasswordChars(printableAlphabets));
return generatedPassword.substring(0,7);
}
public char[] getPasswordChars(char[] pass){
int length = pass.length;
for (int i=0; i char[] useAlph = alphabet;
if (i == 0 && firstAlphabet != null){
useAlph = firstAlphabet;
} else if (i == length - 1 && lastAlphabet != null){
useAlph = lastAlphabet;
}
int size = avoidRepetition(useAlph, pass, i, 2, useAlph.length);
pass[i] = useAlph[rand.nextInt(size)];
}
return(pass);
}
private static int avoidRepetition(char[] alph, char[] pass, int passSize, int repetition, int alphSize){
if (repetition > -1){
int repPos = 0;
while ((repPos = findRepetitions(pass, repPos, passSize, repetition)) != -1){
alphSize -= moveChars(alph, alphSize, pass[repPos+repetition]);
repPos++;
}
if (alphSize == 0) alphSize = alph.length;
}
return alphSize;
}
private static int findRepetitions(char[] pass, int start, int end, int length){
for (int i=start; i boolean onTrack = true;
for (int j=0; onTrack && j if (pass[i+j] != pass[end-length+j]) onTrack = false;
}
if(onTrack) return i;
}
return -1;
}
private static int moveChars(char[] alph, int numGood, char c){
int count = 0;
for (int i=0; i if (alph[i] == c){
numGood--;
char temp = alph[numGood];
alph[numGood] = alph[i];
alph[i] = temp;
count++;
}
}
return count;
}
public void setFirstAlphabet(char[] alphabet){
if (alphabet == null || alphabet.length == 0){
this.firstAlphabet = null;
} else {
this.firstAlphabet = alphabet;
}
}
public void setLastAlphabet(char[] alphabet){
if (alphabet == null || alphabet.length == 0){
this.lastAlphabet = null;
} else {
this.lastAlphabet = alphabet;
}
}
public void setAlphabet(char[] alphabet){
if (alphabet == null) throw new NullPointerException("Null alphabet");
if (alphabet.length == 0) throw new ArrayIndexOutOfBoundsException("No characters in alphabet");
this.alphabet = alphabet;
}
public static void main(String args[])
{
final char[] PRINTABLE_ALPHABET = {
'0','1','2','3','4','5','6','7','8',
'9','A','B','C','D','E','F','G','H','I','J',
'K','L','M','N','O','P','Q','R',
'S','T','U','V','W','X','Y','Z',
'a','b','c','d','e','f','g','h','i','j',
'k','l','m','n','o','p','q','r',
's','t','u','v','w','x','y','z',};
PasswordGenerator pg = new PasswordGenerator();
pg.setAlphabet(PRINTABLE_ALPHABET);
pg.setFirstAlphabet(PRINTABLE_ALPHABET);
pg.setLastAlphabet(PRINTABLE_ALPHABET);
System.out.println("Generated Password:"+pg.generatePassword(PRINTABLE_ALPHABET));
}

}
__________________
M0h@n
t_mohan is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following User Says Thank You to t_mohan For This Useful Post:
Dharmendra Singh (21-09-06)
Old 21-09-06, 12:55 PM   #4 (permalink)
Junior Member
 
Join Date: Sep 2006
Posts: 24
Thanks: 7
Thanked 0 Times in 0 Posts
Thanks: 7
Thanked 0 Times in 0 Posts
Rep Power: 3 Dharmendra Singh is on a distinguished road
Re: how can i create the 7 digit AlfaNumeric Password .

Thanks Mohan.T to clear my concept i wil try it?
Bye
Dharmendra Singh
Dharmendra Singh is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 21-09-06, 01:02 PM   #5 (permalink)
Junior Member
 
Join Date: Sep 2006
Posts: 24
Thanks: 7
Thanked 0 Times in 0 Posts
Thanks: 7
Thanked 0 Times in 0 Posts
Rep Power: 3 Dharmendra Singh is on a distinguished road
Re: how can i create the 7 digit AlfaNumeric Password .

Quote:
Originally Posted by t_mohan View Post
Hi Dharmendhra,

Probably this could help you , i wrote a program which generates a password randomly, but it generates only numeric password. pls try to enhance it which meets your requirements

import java.util.Date;
import java.util.Random;

public class PasswordGenerator {
private Random rng = null;

public PasswordGenerator(){
rng = new Random((new Date()).getTime());
}

public String generatePassword() {
StringBuffer buff = new StringBuffer();
while (buff.length() < 8) {

buff.append(Math.abs(rng.nextInt()));
}

return buff.substring(0, 7);
}
public static void main(String args[])
{
PasswordGenerator pg = new PasswordGenerator();
System.out.println("Generated Password:"+pg.generatePassword());
}
}

It is a compiled code and executing fine

If u need any help, post a reply again

Thanks

Mohan.T

Last edited by Dharmendra Singh; 21-09-06 at 01:05 PM.
Dharmendra Singh is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 22-09-06, 05:29 PM   #6 (permalink)
Junior Member
 
Join Date: Sep 2006
Posts: 24
Thanks: 7
Thanked 0 Times in 0 Posts
Thanks: 7
Thanked 0 Times in 0 Posts
Rep Power: 3 Dharmendra Singh is on a distinguished road
Re: how can i create the 7 digit AlfaNumeric Password .

Hi Mohan.T
Your code for generate the AlfaNumeric Password is not compile it is showing the error.plz send me compile code.i m waiting ur reply.
Thanks
Dharmendra singh
Dharmendra Singh is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 22-09-06, 07:35 PM   #7 (permalink)
Moderator
 
t_mohan's Avatar
 
Join Date: Apr 2006
Location: India
Posts: 636
Thanks: 57
Thanked 78 Times in 63 Posts
Thanks: 57
Thanked 78 Times in 63 Posts
Rep Power: 17 t_mohan is a splendid one to behold t_mohan is a splendid one to behold t_mohan is a splendid one to behold t_mohan is a splendid one to behold t_mohan is a splendid one to behold t_mohan is a splendid one to behold t_mohan is a splendid one to behold
Re: how can i create the 7 digit AlfaNumeric Password .

Hi Dharmendra,

I dont know how it has missed some of the text while copying . i wrote my code and compiled it and tested. After making sure it is working i copied it on the forum. anyway i sent u the code to ur mail id. Pls find the attached File in ur mail box singh_dharmendra2001@yahoo.co.in from mohan.thutta@gmail.com

Thank You
Mohan.T
__________________
M0h@n

Last edited by t_mohan; 22-09-06 at 07:40 PM.
t_mohan is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 28-02-07, 11:19 AM   #8 (permalink)
Junior Member
 
Join Date: Feb 2007
Age: 28
Posts: 17
Thanks: 1
Thanked 0 Times in 0 Posts
Thanks: 1
Thanked 0 Times in 0 Posts
Rep Power: 2 golikrishna is on a distinguished road
how to retrieve contents from particular site

Hi ,
i am getting one problem tha is "i want to retrieve the contents from any web page into my own page,so how can i retrieve the contents of the web page,and how can i display multiple windows in my own page and every window should refresh for every 30 sec ,could u tell me plzzz
golikrishna is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 28-02-07, 05:14 PM   #9 (permalink)
Moderator
 
t_mohan's Avatar
 
Join Date: Apr 2006
Location: India
Posts: 636
Thanks: 57
Thanked 78 Times in 63 Posts
Thanks: 57
Thanked 78 Times in 63 Posts
Rep Power: 17 t_mohan is a splendid one to behold t_mohan is a splendid one to behold t_mohan is a splendid one to behold t_mohan is a splendid one to behold t_mohan is a splendid one to behold t_mohan is a splendid one to behold t_mohan is a splendid one to behold
Re: how to retrieve contents from particular site

I couldnot understand ur question krishna,pls be clear then probably i can help you.
__________________
M0h@n
t_mohan is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
WHAT IS CONNECTION POOLING? yathish JAVA Technologies 10 19-09-06 02:39 PM
Removing password protection from PDF documents vjsreevs Latest Tech News & Innovations 0 11-06-06 03:43 PM


All times are GMT +6.5. The time now is 09:44 AM.





Search Engine Optimization by vBSEO 3.1.0