I am trying to make a loop that gets passwords from an array list, hashes them, and then passes the hashed passwords back into a Person object.
import java.util.ArrayList;
public class CompanyDatabase {
public ArrayList<Person> getPeople() {
ArrayList<Person> people = new ArrayList<Person>();
String[] u = {"Joe","Stan","Leo","John","Sara","Lauren"};
String[] p = {"pass4321", "asdfjkl", "genericpw", "13579", "helloworld", "companypass"};
for(int j = 0; j < u.length; j++){
Person temp = new Person(u[j],p[j]);
people.add(temp);
}
return people;
}
}
import java.util.ArrayList;
import java.util.Scanner;
public class CompanyDatabaseDriver {
private static Scanner scan = new Scanner( System.in ) );
public static void main(String args[]) {
CompanyDatabase bcData = new CompanyDatabase();
ArrayList<Person> people = bcData.getPeople();
Hash_SHA hasher = new Hash_SHA();
for(int i=0;i<people.size();i++){
System.out.println(people.get(i).getPassword());
}
// i know i have to use a variation of
// String hashString = hasher.getHash(passString);
// but do not really know what to do with it
}
}
public class Person {
private String username;
private String password;
public Person(String un, String pw){
username = un;
password = pw;
}
public void setUsername(String un){
username = un;
}
public void setPassword(String pw){
password = pw;
}
public String getUsername(){
return username;
}
public String getPassword(){
return password;
}
}
Currently I just have the loop printing out the plain text passwords and then ending the loop. Any help would be amazing. Thank you very much.