Random Password Generator
Hi everyone, I made this Password Generator that does what I want, but I'd like to extend its functionality. Right now it creates a random password from an array of letters and numbers.
import java.io.*;
import javax.swing.*;
import java.util.*;
*Version 0.1:
*creates several random passwords using numbers,
*uppercase and lowercase letters
*Version 0.2:
*add a save feature
public class PasswordGeneratorV02
public static void main(String[] args)
* Define all variables and create all objects here
// create the Number and Letter arrays
Integer[] numberList = new Integer[10];
String[] letterList = new String[12];
//Variable to continue the while loop
Boolean cont = true;
//Scanner used to continue or not
Scanner input = new Scanner(System.in);
//Stores the user input
String answer;
* End variables
//fill the letterList array
//need to find a more efficient way to do this
//and add all the letters of the alphabet
letterList[0] = "a";
letterList[1] = "F";
letterList[2] = "c";
letterList[3] = "R";
letterList[4] = "y";
letterList[5] = "O";
letterList[6] = "p";
letterList[7] = "W";
letterList[8] = "q";
letterList[9] = "n";
letterList[10]= "E";
letterList[11]= "w";
// fill it with numbers 0-9
for (int i=0; i < numberList.length; i++)
numberList= i;
// make both arrays lists so we can shuffle them
List list = Arrays.asList(numberList);
List list2 = Arrays.asList(letterList);
//Start the output to user
System.out.println("Welcome to the random password generator!");
System.out.println("This program will create a random 20 character alphanumeric password.");
System.out.println();
//Shuffles the array contents then prints it out.
while(cont == true)
// shuffle the list
Collections.shuffle(Arrays.asList(numberList));
Collections.shuffle(Arrays.asList(letterList));
// print out the shuffled array contents
for (int i : numberList)
System.out.print(i + letterList[i]);
System.out.println();
System.out.println("Press Enter for a new password. Q to quit.");
answer = input.nextLine();
//check to see if user wants to quit
if(answer.equalsIgnoreCase("q"))
cont = false;
System.out.println("Goodbye...");
}I would like to change/add two things.
1st, I want to change the array of letters to include the full alphabet(lower and uppercase), with out having to type it in.
2nd, I would like to add a save feature where the user types in "S" at the prompt and it will allow them to save the password as a text file.
Thanks in advance.
Ok well, I googled around and found something.
The output now displays letters, but it no longer shuffles them around. For example:
6A8B7C4D2E0F5G1H3I9J
Every letter is just the next letter in the alphabet. How would I shuffle an array of chars?
New code:
import java.io.*;
import javax.swing.*;
import java.util.*;
*Version 0.1:
*creates several random passwords using numbers,
*uppercase and lowercase letters
*Version 0.2:
*add a save feature
public class PasswordGeneratorV02
public static void main(String[] args)
* Define all variables and create all objects here
// create the Number and Letter arrays
Integer[] numberList = new Integer[10];
char[] letterList = "ABCDEFGHIJKLMNOPQRSTUWVXYZabcdefghijklmnpqrstuvwxyz".toCharArray();
//Variable to continue the while loop
Boolean cont = true;
//Scanner used to continue or not
Scanner input = new Scanner(System.in);
//Stores the user input
String answer;
* End variables
// fill it with numbers 0-9
for (int i=0; i < numberList.length; i++)
numberList= i;
// make both arrays lists so we can shuffle them
List list = Arrays.asList(numberList);
List list2 = Arrays.asList(letterList);
//Start the output to user
System.out.println("Welcome to the random password generator!");
System.out.println("This program will create a random 20 character alphanumeric password.");
System.out.println();
//Shuffles the array contents then prints it out.
while(cont == true)
// shuffle the list
Collections.shuffle(Arrays.asList(numberList));
Collections.shuffle(Arrays.asList(letterList));
// print out the shuffled array contents
for (int i=0;i<numberList.length;i++)
System.out.print(numberList[i] + String.valueOf(letterList[i]));
System.out.println();
System.out.println("Press Enter for a new password. Q to quit.");
answer = input.nextLine();
//check to see if user wants to quit
if(answer.equalsIgnoreCase("q"))
cont = false;
System.out.println("Goodbye...");
Similar Messages
-
Getting the random password to user email or manager email
Hi All,
when the user is created then the random password generated successfully.
Now i want sent the generated password to User Email or Manager Email.
For that how can I approch for this.
Regards,
ADRWrite your logic to send email in the same class which is responsible for generating password for user:
Re: Send Mail via java code but using Mail Definitions -
Hi, I'm not particularly hot on java but thought you might know the answer to this question:
Is it possible for a Java random password generator to give a "rude" password? Recently I've seen a password generated for a user that happened to be very offensive. I guess it is possible?
Any thoughts?Hi, I'm not particularly hot on java but thought you might know the answer to this question:
Is it possible for a Java random password generator to give a "rude" password? Recently I've seen a password generated for a user that happened to be very offensive. I guess it is possible?
Any thoughts? -
How to create a javabean that generate random password?
May i know how to create a javabean that can generate random password?
that include character and string
and length of 10.i created a class file for my java bean
package autogenerate;
import java.util.*;
public class GeneratePwId
private int MemId;
private String Passwd;
public GeneratePwId(){}
public String getPasswd()
return this.Passwd;
public void setPasswd()
char[] letters = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
'J', 'K', 'L', 'M', 'N', 'P', 'R', 'T',
'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c',
'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k',
'm', 'n', 'p', 'q', 'r', 's', 't', 'u',
'v', 'w', 'x', 'y', 'z', '0', '1', '2',
'3', '4', '5', '6', '7', '8', '9' } ;
String pwd = "" ;
while( pwd.length() < 10 )
pwd += letters[ (int)( Math.random() * letters.length ) ] ;
this.Passwd = pwd;
i successfully compile my java file. and try to test it by writing a jsp file.
here is my jsp code
<html>
<head>
<title>
Try retrieving password
</title>
</head>
<body>
<jsp:useBean class"autogenerate.GeneratePwId" id="bean0" scope="page"/>
<%=bean0.getPasswd()%>
</body>
</html>
but i encounter this error
org.apache.jasper.compiler.ParseException: /jsp/GetPasswd.jsp(7,18) Attribute class has no value
anyone can teach me how to solve this problem?
thanks a alot! -
Parameterized Active Sync Form generating random password
Hi im looking for an sample of an Parameterized Active Sync Form which generates a random password.
Thanks!
Michael--I think password from AD not put in to activeSync.
--Why?
You cannot change the user's password from the activeSync RA. The password is encrypted in Active Directory and you can't decrypt it.
You can read the Idm Resources Reference - Active Directory. There's a table with all the supported fields; the userPassword field is write-only.
If you want to take the AD password and send it to IDM, you want to use Password Sync.
Good luck -
How can I generate random password
Hello...
I use oracle 10g for windows,,,I have an employee table , there are a lot of colunms , their names are employee_name , employee_id ,employee_pass .....
employee_pass colunm is empty
I want to generate random password for employee_pass colunm
How can I generate random password for employee_pass colunm
thanks
omer faruk akyuzlu
in TurkeySQL> exec dbms_random.seed(to_char(sysdate, 'sssss'))
PL/SQL procedure successfully completed.
SQL> select dbms_random.string('X', 8) from dual
2 /
DBMS_RANDOM.STRING('X',8)
4YT1H150
SQL> select dbms_random.string('X', 8) from dual
2 /
DBMS_RANDOM.STRING('X',8)
WIA3QCIP
SQL> Please be aware that storing the actual passwords in a the EMPLOYEES table is a very bad idea. Oracle has a pretty good password implementation. It's not perfect but it's a darn site better than hand-rolling our own.
Cheers, APC -
How to generate random password
Hi Experts,
i using some cmdlets to generate random password.
$ascii=$NULL;
For ($a=97;($a –le 122);$a++) {$ascii+=,[char][byte]$a }
$No_of_password = 6
$length_of_password = 10
$TempPassword=$NULL # To store single password
$Morepassword=@() # Variable to 'X' no. of passwords
for ($lp=0; $lp -le $count; $lp++ )
For ($loop=1; $loop –le $length; $loop++)
$TempPassword+=($ascii | GET-RANDOM) # this generate the random password
$morepassword[$lp]= $TempPassword
$morepassword # This should give the all random password
Output is like ---
=zM;HFuElY
=zM;HFuElYp88<kqTOVM
=zM;HFuElYp88<kqTOVMfS1xR01VzY
=zM;HFuElYp88<kqTOVMfS1xR01VzY4<$wG%Z>ft
=zM;HFuElYp88<kqTOVMfS1xR01VzY4<$wG%Z>ft=a&ME7>&3T
=zM;HFuElYp88<kqTOVMfS1xR01VzY4<$wG%Z>ft=a&ME7>&3T$98v$b>jSU
This is not required output. It should give the output like
=zM;HFuElY
p88<kqTOVM
fS1xR01VzY
4<$wG%Z>ft
=a&ME7>&3T
$98v$b>jSU
Total 6 passwords with a length of 10
How do create a array like this ?I agree with Fred but here i shwo to manage two loops with PowerShell.
$pwdchars=33..122|%{[char]$_}
1..6|
ForEach-Object{
$pwd=''
1..10 |
ForEach-Object{
$pwd+=$pwdchars | GET-RANDOM
$pwd
It is usually always better to write less code and to use the code correctly. YOu have guessed at mmost of the code but have not used consistent variables. My guess is that you have tried to modify somecode you found. Look at this code
to see how easy it is to build loops in PowerShell
¯\_(ツ)_/¯ -
How to generate random password as per password policy by knowing the resou
Hi,
Any body tell me, how to generate random password as per password policy by knowing the resource object in OIM11g
Regards,
Nishith NayanHi Nayan,
You can try below code snippet:
UserRepository ur = new DBUserRepository();
UserInfo user = ur.getUserInfo(userKey);
ResourceRepository rrepo = new ResourceDBRepository();
Resource resource = rrepo.findResource(resourceName);
PasswordPolicyAssignmentsRepository par = new PasswordPolicyAssignmentsDBRepository();
PasswordPolicyRepository ppr = new DBPasswordPolicyRepository();
List passwordPolicyAssignments = par.getPasswordPolicyAssigments(resource);
PasswordPolicy passwordPolicy;
PasswordPolicyAssignment passwordPolicyAssignment = (PasswordPolicyAssignment) passwordPolicyAssignments.get(0);
if (isApplicable(passwordPolicyAssignment, getMappedAttributes(userInfo.getAttributes()))) {
passwordPolicy = ppr.find(passwordPolicyAssignment.getPasswordPolicyID());
RandomPasswordGeneratorImpl rpg = new RandomPasswordGeneratorImpl();
password = rpg.generatePassword(userInfo, passwordPolicy);
regards,
gyan -
Generating a random password and sending a userid through mail to the user
HI,
I have a field named UserID in the process form,this user id can only be accessed by the GIA PROVISIONING ANALYST for updation of the userid to provision the resource to some related id of the user .I want to send this user ID from the process form in a mail to the target user,moreover i also want to include a password field nd also send a random password to the user.In short i want to obtain the values of user id and password send it in a email to the target userThis is the body of my email template:
Request number: <Request Information.Request ID>
The following access has been granted:
Name: <Request Information.List of user targets being requested for>
ID: <User Profile Information.User Login>
Resource: <Object Information.Object Name>
Updated UserID:<Process Data Information.RSS User Name>
In this case the "Updated UserID " is to be obtained from the Process Form and has to be sent in the mail.
"RSS User Name" is the field label in the process form.when this email is sent iam not able to retrieve the values .The same statement ie."Updated UserID:<Process Data Information.RSS User Name>" is displayed in the email .
I have even tried giving <Process Information.RSS User Name> and <Process Data Information.Process Name.RSS User Name> still the value is not obtained.Plz guide me through this. -
Disable random Password generation button on Reset Password popup window.
Hi ALL,
We have a new requirement when user click on reset password tab on "Modify User" page, a pop up window will open with two options :
1) Manually change the Password
2) Auto-generate the Password (Randomly generated)
I want to remove or disable this 2nd option. Can you please guide me what necessary changes required?
Thanks,
AmitIt's easy enough to generate a random password. Use a
constant string containing your alphabet (different
systems have different rules about what characters
are allowed). Then us Random first to generate a
suitable length, then to pick a character from your
alphabet for each slot. If there are further rules
(e.g. "must contain at least one digit") then check
the password you've just generated and if it fails
the test, simply try again.
But this isn't a particularly good system. It allows
anyone to harrass a user by changing their password
if they can guess their user name.
The approach I favour is to send the user a one-time
click-thru URL in an e-mail which allows them to set
their password to anything they chose. That needs a
special table in some data base. You generate a
random token which acts as a one-shot password on a
special "change password" page. As soon as the click
through has been used then the database entry is
deleted so that the token is invalidated. You should
also invalidate the token if they log on in the
normal way.I agree that the 'forgot your password' feature is nasty. I mean, we are normally enjoined from saying "invalid user id" or "invalid password", we have to say "invalid user id / password combination" or something to that effect. But by providing the 'forgot your password' feature, it would be trivial to write a bot to see which sites provide this, determine a good page from a bad (e.g., valid user id) and then have an easier time brute-forcing the password. Sad.
On the other hand, I know personally that many companies are concerned with phishing attacks on their customers. As such, they have a blanket policy prohibiting any URL that hits a secured page in any way.
So, what to do? :^(
- Saish -
How to lock a user by using random password?
hello,
i need to lock a user from a target system by pushing in random passwords for the accounts. i am successfully able to create an adapter that can generate a random string, but the place where i am stuck is that where to use it as i just need to lock the user and not delete it. if the corresponding manager approves the suspension then the account needs to be deleted else again the account needs to be enabled.
Please help!
Thanks!ok... sorry...
so what i did is that i have created a resource that has to be provisioned to the user if the user is to be terminated, in which the manager will mention the user to be terminated and the reason.
now OIM has to lock the user till the reason that has been given by the manager is deemed valid by the second level manager.
so for that i have a approval and a process form and processes associsted with them. but the problem is that i need to lock the user using the "Entity Adapter" so i need to do so only in the "Data Object Manager" and thus the problem starts as i dont know where to map the adapter that generates the random password so as to lock the user.
please, if you find anything confusing here, go thru the discussion in the whole of the thread.
Thanks! -
Hi,
I use PHP and MySQL within Dreamweaver
I want my client to be able to generate a new random password
for a new member.
How should I do this?
Create a list of random passwords or
can I create it on the fly while registering a new member?
I don't want the new member to create his own password.
Thanks to all people contributing to this forum.
I learned a lot here allready.
I hope you can also help me out with this one.
Jos> can I create it on the fly while registering a new
member?
That would be the best way.
I have used this to produce random, 8 character passwords
(the database part
is to make sure that they are unique) -
function randomkeys($length)
$pattern =
"234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
for($i=0;$i<($length);$i++)
if(isset($key))
$key .= $pattern{rand(0,strlen($pattern)-1)};
else
$key = $pattern{rand(0,strlen($pattern)-1)};
return $key;
mysql_select_db($database_selectData, $selectData);
$query_rsPasswords = "SELECT contactPassword FROM
tblcontactdata";
$rsPasswords = mysql_query($query_rsPasswords, $selectData)
or
die(mysql_error());
$row_rsPasswords = mysql_fetch_assoc($rsPasswords);
$totalRows_rsPasswords = mysql_num_rows($rsPasswords);
$masterList=array();
$passwords=array();
$rsPasswordList = mysql_query("SELECT contactPassword FROM
tblcontactdata",$selectData)
or die(mysql_errno()." : ".mysql_error());
while ($rec = mysql_fetch_row($rsPasswordList)){
$passwords[] = $rec[0];
$unique = false;
while ($unique === false) {
$temp = randomkeys(8); // this is generating a random
8-character p/w
if(!in_array($temp, $passwords)) {
$newPassword = $temp;
$unique = true;
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go
- DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs,
Tutorials & Resources
==================
"arnhemcs" <[email protected]> wrote in
message
news:[email protected]...
> Hi,
>
> I use PHP and MySQL within Dreamweaver
> I want my client to be able to generate a new random
password for a new
> member.
>
> How should I do this?
> Create a list of random passwords or
> can I create it on the fly while registering a new
member?
> I don't want the new member to create his own password.
>
>
>
>
> Thanks to all people contributing to this forum.
> I learned a lot here allready.
>
> I hope you can also help me out with this one.
>
> Jos
> -
Hi All,
We have a link on login page "Forgot Password" ?
As users clicks the link, idea is he goes to page that has emails address and submit button.
As user enters his emails address and clicks submit, the mechanism gemerates a new password and sends it over to his email address.
My question is, "I dont know how to generate that new random password."
Is there a code around, that I can use ?
thanks a lot,
ppIt's easy enough to generate a random password. Use a
constant string containing your alphabet (different
systems have different rules about what characters
are allowed). Then us Random first to generate a
suitable length, then to pick a character from your
alphabet for each slot. If there are further rules
(e.g. "must contain at least one digit") then check
the password you've just generated and if it fails
the test, simply try again.
But this isn't a particularly good system. It allows
anyone to harrass a user by changing their password
if they can guess their user name.
The approach I favour is to send the user a one-time
click-thru URL in an e-mail which allows them to set
their password to anything they chose. That needs a
special table in some data base. You generate a
random token which acts as a one-shot password on a
special "change password" page. As soon as the click
through has been used then the database entry is
deleted so that the token is invalidated. You should
also invalidate the token if they log on in the
normal way.I agree that the 'forgot your password' feature is nasty. I mean, we are normally enjoined from saying "invalid user id" or "invalid password", we have to say "invalid user id / password combination" or something to that effect. But by providing the 'forgot your password' feature, it would be trivial to write a bot to see which sites provide this, determine a good page from a bad (e.g., valid user id) and then have an easier time brute-forcing the password. Sad.
On the other hand, I know personally that many companies are concerned with phishing attacks on their customers. As such, they have a blanket policy prohibiting any URL that hits a secured page in any way.
So, what to do? :^(
- Saish -
Reset Password :Non Random Password
When an admin resets a users password via Reset User Password workflow a random password is generated. In the Reset User Password workflow I am unable to identify the activity that does the generation. I would like to instead set a default static password, is this possible?
Thank you,
ClearHi,
Actually password generation is part of Reprovision process in Reset User Password workflow. can see below trace :
Argument op = reProvision
Argument accountId = KSolanki
Argument options = object
Argument retryEnable = true
Calling application 'com.waveset.provision.WorkflowServices'
Application requested argument op
Application requested argument user
Application requested argument options
Application requested all arguments
Application requested argument subject
Application reference retryInfo = null
Application requested argument retryEnable
Application assignment retryInfo.timeout = 0
Application reference retryInfo =
<Object>
<Attribute name='timeout'>
<Integer>0</Integer>
</Attribute>
</Object>
Application requested argument doResources
Application reference AllowPasswordGeneration = null
Application requested argument allowPasswordGeneration_
~ Ketan -
Custom mass password generate program
Hi,
I'm requried to develop a mass password generate program to be sent to the user via mail, i'm using RSEC_GENERATE_PASSWORD function module to to generate the random password, but how do i update the user password that puzzles me, is there any process/ class/method/ FM/ BADI etc that will update/ create a user, has anyone done this before, appreciate any adivse/ pointersHi Lawrence,
You can do this in 2 ways viz:-
1. Use BAPI_USER_CREATE1 to create new users in system and assign initial password to the users just created by BAPI_USER_CHANGE. After this you can use function module SUSR_USER_BUFFER_AFTER_CHANGE to refresh the buffer.
2. Do a BDC of SU01 transaction with proper check of authority object.
I would recommend option 1. Please check and let me know if you face any problems.
Reward points if this helps.
BR,
Atanu
Moderator Message: Asking for points violates the Forum Rules Of Engagement
Edited by: Suhas Saha on Jul 26, 2011 10:48 PM
Maybe you are looking for
-
Decrypt the encrypted password
Hi there, I have been scratching my head for some time to fix one issue. We are planning to change the plateform/technology and we need to bring over existing login to new system. In order to have the same password I need to decrypt the password befo
-
Windows 7 64-bit Itunes crashes
For the last couple of months when it seems that my itunes is done updating my iphone 3GS I get an error message saying itunes needs to close. Any ideas on how to fix this would be appreciated.
-
hello friends, Please help me out...iam in urgent help..iam not getting answer for this .. Using zlib java.. I have a zipfile named prabhu.zip It contains prabhu\prabhuimage\imagefiles right now iam able to unzip only files in current folders..i mean
-
I created a spreadsheet using Microsoft office 2010 Excel. When I open the sheet using Numbers, the formatting changes. How do I fix this?
-
Problem with Gantt table (Business graphic)
Hi everybody, I got a problem with an gantt table (Business graphic) in an old project. This gantt table is used to display the timeline of used ressources. The Problem here his that, if the last row of the gantt table is filled, this row will not be