Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners random pass generator

Have Programming Question? Ask it here!
 
 
 


Kim
random pass generator
1 Answer(s)      4 years and 9 months ago
Posted in : Java Beginners



Advertisement
View Answers

July 17, 2009 at 3:32 PM


Hi Friend,

Try the following code:

import java.io.*;
import java.util.*;
import java.net.*;

public class NamePass {
public static void main(String[] args)throws Exception {
FileReader inStream,inStream1;
BufferedReader in,in1;

String passwords="";
String pass="";
String name="";
Random r = new Random();
int[] integers = new int[20];
for (int i = 0; i < integers.length; i++) {
integers[i] = r.nextInt(10000000);
}
for (int i : integers) {
passwords+=Integer.toString(i)+"\n";
}

File myFile = new File("passwords.dat");
FileOutputStream outStream = new FileOutputStream(myFile);
PrintWriter out = new PrintWriter(outStream);
out.println(passwords);
out.close();
String p[]=new String[20];
String n[]=new String[20];

inStream1 = new FileReader(myFile);
in1 = new BufferedReader(inStream1);
String passwordData="";
for (int i=0;i<20;i++){
p[i]=in1.readLine();
pass+=p[i];
}

inStream= new FileReader("names.dat");
in = new BufferedReader(inStream);
for (int i=0;i<20;i++){
n[i]=in.readLine();
name+=n[i];
}


java.util.List<String> list = new ArrayList<String>();
for(int i = 0; i < n.length; i++) {
String line = n[i]+" "+p[i];
list.add(line);
}
System.out.println(list);
writeToFile(list, "NamePass.dat");
}
private static void writeToFile(java.util.List<String> list, String path) {
BufferedWriter out = null;
try {
File file = new File(path);
out = new BufferedWriter(new FileWriter(file));
for (String s : list) {
out.write(s);
out.newLine();
}
out.close();
} catch(IOException e) {}
}
}

Thanks


Related Tutorials/Questions & Answers:
random pass generator - Java Beginners
random pass generator  Write a program (name the program and class... inStream,inStream1; BufferedReader in,in1; String passwords=""; String pass=""; String name=""; Random r = new Random(); int[] integers = new int[20
PHP Simple password generator
PHP Simple password generator In this tutorial I will be showing you how to create a random password using nothing but loops and random letters. For extra... the loop of creating it, using the $min and $max we can get a random length
Advertisements
Generator in Hibernate
Generator in Hibernate  What is the generator in hibernate
Data Generator
Data Generator Data Generator is free open source script that is designed to create the application, which can be used to generate a large sum of data... JavaScript, PHP and MySQL. Characteristics Data generator is browser
Random classes
Random classes  Hello... What is Random class? What's the purpose
Random classes
Random classes  Hello... What is Random class? What's the purpose
Random classes
Random classes  Hello... What is Random class? What's the purpose
Generating Random Number
(): This method returns a random number in random number generator's sequence. If you pass... to the random number generator. Here is the code of the program... Generating Random Number     
random numbers - Java Beginners
java.util.*; class RandomNumberExample { static Random generator = new Random...random numbers  write a program to accept 50 numbers and display 5...(); System.out.println("Random numbers are: "); int random[]=new int[5]; for(int i=0;i
random number
random number  Sir could u please send me the code registration form of roseindia.net with image varification
random number
random number   Please How do I generate a program that gives me random integer from 115 to 250? Using java.util.random. Thank you very much!  ...[] args){ int min = 115; int max = 250; Random random = new Random
random numbers
random numbers  hi.. i am creating a website and on feedback form to authenticate user i want to generate a random number on label.if user types that number correctly in textbox then he is allowed to submit feedback otherwise
Hibernate Generator
This tutorial is helpful in understanding the concept of hibernate generator
Pick at Random
the entry from the array before selecting another name at random
random numbers
random numbers  Hi I need some help with the code for the this program. This program should randomly choose a number between 1 and 1000, and then challenge the user to guess what it is, giving hints ('too high!' or 'too low
PASS value
PASS value  javascript to pass value to other html file
random numbers - Java Beginners
RandomNumberExample { static Random generator = new Random(); public static int get (int[] array...random numbers  Hello i need this code to be modified for me to display the random numbers, but not twice or more. I mean i need a number
J2ME Random Number
this random number generator's sequence and the setSeed method is used to sets the seed of this random number generator using a single long seed and finally... J2ME Random Number      
Random Access File.
Random Access File.  Explain Random Access File
Understanding Hibernate <generator> element
to pass the parameter (s) to the  class. Here is the example of generator... about hibernate <generator> method in detail. Hibernate generator element... by the generator method to be used in different situations. The <generator> element
hibernate metamodel generator
In this section, you will learn about hibernate metamodel generator
using random number
using random number  generate a 10 digit number using random number and display the length of longest increasing series
Sequence generator problem - JDBC
Sequence generator problem  Dear sir, I have created one table by name massemailsendingdetails. CREATE TABLE MASSEMAILDETAILS( ID...) ); Then i created a sequence generator for an id as follows CREATE SEQUENCE
Generator Tag
; } } Create a jsp page where the generator tag...;  Output of the  Generator Tag Example
Random Access File class
Random Access File class  Write a short note on Random Access File class.   Please visit the following link: Java Random Access File
understanding buttons :JSP random no program
understanding buttons :JSP random no program  I hav java random no generator program but i need to implement it in JSP such that page generates random no between 100 and 200 on loading and on clicking submit button it ives
Random Numbers - shuffling
Random(); // Random number generator int[] cards = new int[52... is described at the bottom. Shuffling: Random numbers without replacement The random number methods generate numbers with replacement. This means
getting random number in java
getting random number in java  getting random number in java Hi everyone, i am trying to get a random number in a particular range. for example random numbers between 1 to 100 in Java. Though i m new to Java, i have tried many
Generate Random Numbers
Generate Random Numbers  hi,,, Please give me answer with example How do you generate random numbers within a given limit with actionscript... This function generate random numbers with in given limit
Random data - Java Beginners
Random data  hi friend, I want to ask how to make random data. i has example word like this : Gaza! Gaza! Palestina merdeka! how to make random like : Azag! Azag! Anitselap akedrem! thank's
RANDOM ACCESS FILE CONCEPT
RANDOM ACCESS FILE CONCEPT  In a random access file, first write the alphabets a,b, c, d till z. Read the file in reverse order and print it on screen
using random number
using random number  generate 10 number and display the length of longest incresing series
using random number
using random number  generate 10 digit number and display the length of longest incresing swries
Random numbers - Introduction
Java NotesRandom numbers - Introduction When to use random numbers There are many types of programs that use random numbers. Game programs use them... situation, or a deck of cards must be shuffled. Simulations usually use random
Random in jsp
Random in jsp          Random numbers are the numbers that are determined entirely by chance. User does not have any control over the working of random numbers
RANDOM ACCESS FILE CONCEPT
RANDOM ACCESS FILE CONCEPT  Write a program that stores the names of four employees in an array of strings. Store the contents of the array in an alphabetical order in a file and display it back on console. Do not use
Random numbers - Development process
Random numbers  hi, How to generate unique random numbers between range like(10 to 50)  Hi friend, class RandomNumber { public static void main(String[] args) { //set the variable aNumber
Random Creation of password
Random Creation of password  Dear Sir I have created a form with some details in it.When clicking on the submit button it gives me a password... to generate a random password and insert into database... Please help me out
RANDOM ACCESS FILE CONCEPT
RANDOM ACCESS FILE CONCEPT  Write a program to use a File object and print even numbers from two to ten. Then using RandomAccessFile write numbers from 1 to 5. Then using seek () print only the last 3 digits
Hibernate generator Element
; type="long" column="Id" > <generator class="..., short or int. assigned This generator lets to assign an identifier... strategy if generator element is not specified. select
Generating random numbers in a range with Java
Generating random numbers in a range with Java  Generating random numbers in a range with Java
random color fill
random color fill   Hi I am trying to create a randomly color filled oval but the outcome is a black filled oval this is the code: package...; Random rcolor = new Random(); int r = rcolor.nextInt(255); int g1
org.hibernate.MappingException: could not instantiate id generator
" org.hibernate.MappingException: could not instantiate id generator
org.hibernate.MappingException: could not instantiate id generator
" org.hibernate.MappingException: could not instantiate id generator
org.hibernate.MappingException: could not instantiate id generator
" org.hibernate.MappingException: could not instantiate id generator
org.hibernate.MappingException: could not instantiate id generator
" org.hibernate.MappingException: could not instantiate id generator
RANDOM ACCESS FILE CONCEPT
RANDOM ACCESS FILE CONCEPT  Write a program to write the details of an employee to a file. Details such as year of joining, department code, employee name and salary should be included. You must use RandomAccessFile
pass method reference in java
pass method reference in java  How to pass method reference in Java
Is Java pass-by-reference?
Is Java pass-by-reference?  Is Java pass-by-reference
how to generate random questions - Java Beginners
"; Random generator = new Random(); int r = generator.nextInt(questionAr.length...how to generate random questions  i am designing a test engine, i want my questions to be generated randomly. how can i do this?   Hi
Advertisements
 

 

 

DMCA.com