. Java Cart . Java Cart Password java
Java Cart Password java
package cart;
//Password - has methods to store passwords
//should handle any encryption of the password
//author - Lawrence Truett - FluffyCat.com
//date - August 12, 2003 - San Diego, CA
public final class Password {
private String password = null;
public Password() {}
public Password(String passwordIn) {
this.setPassword(passwordIn);
}
//returns password, should be encrypted by this point -
//but we still don't want it leaving this class.
private String getPassword() {return password;}
//sets the password, should be encrypted here
public void setPassword(String passwordIn) {
this.password = this.encrypt(passwordIn);
}
public boolean equalsPassword(String passwordToCompare) {
if (Password.encrypt(passwordToCompare).equals(getPassword())) {
return true;
}
else {return false;}
}
private static String encrypt(String passwordIn) {
//need your own fancy encrypting algo here
return passwordIn;
}
public String toString() {
return ("password class - the password is a secret");
}
}
download source, use right-click and "Save Target As..." to save with a .java extension.
| Sign In |
| to add the first comment for Java Cart Password java. |