Code.GeekInterview.com
  I am new, Sign me up!
 
Code Samples Java
 

Random Password Generation function


Code ResourceAuthor: Kiran.jakkaraju  

Difficulty Level:

Published: 7th Nov 2006   Read: 2723 times  

Filed in: Java
Add Comment


 


The generatePassword() method give you a random password.
Using SecureRandom algorithm, generate a random number and add it with any string as project_name  for a temporary password. We can use this for generating a random/different kind of passwords. This can be used in Forgot password/ Reset Password/ kind of programs.

 


Sample Code
  1.  
  2. /**
  3.  
  4.     * generatePassword() method give you a random password.
  5.     * Using SecureRandom algoritham, generate a random number and add it with prj_name string
  6.     * for a temporary password.
  7.     *
  8.  
  9. **/
  10.  
  11. public String generatePassword() {
  12.  
  13.  
  14. int randnumb = r.nextInt();
  15.  
  16. if(randnumb<0)
  17.  
  18. randnumb=randnumb*(-1);
  19.  
  20. StringBuffer newPassword = new StringBuffer();
  21.  
  22. newPassword.append(“prj_name”);
  23.  
  24. newPassword.append(String.valueOf(randnumb));
  25.  
  26. return newPassword.toString();
  27.  
  28. }
  29.  
Copyright GeekInterview.com


Next Article: Send email using Gmail Mail Server


 

Latest Code Samples

 

Popular Code Samples

 

Related Code Samples

 

Post Comment


Members Please Login

Name:  Email: (Optional. Used for Notification)

Title:
 
Comment:
Validation Code: <=>  (Enter this code in text box)





Popular Coders

# Coder NameHits
1. iamdvr35780
2. venki_madesh30859
3. srinivasaraobora22528
4. bora_srinivasarao11756
5. Kiran.jakkaraju4621
6. parmod kumar duhan4509
7. chowsys3973
8. Venkateswara Rao3716
9. Raju3402
10. Vamshidhar Matam2298

Active Coders

Refined Tags

 

Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact  

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape