package auth;
public class PasswordHash {
public String algorithm;
public Integer iterations;
public String salt;
public String hash;
public PasswordHash(String algorithm, Integer iterations, String salt, String hash) {
this.algorithm = algorithm;
this.iterations = iterations;
this.salt = salt;
this.hash = hash;
}
public PasswordHash(String serializedPassword){
String[] parts = serializedPassword.split("\\$");
this.algorithm = parts[0];
this.iterations = Integer.valueOf(parts[1]);
this.salt = parts[2];
this.hash = parts[3];
}
public String toString(){
StringBuffer buf = new StringBuffer();
buf.append(algorithm);
buf.append("$");
buf.append(iterations);
buf.append("$");
buf.append(salt);
buf.append("$");
buf.append(hash);
return buf.toString();
}
}