Java Cart .

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");
    }    
}
To download source right-click here and "Save As...".
Comments
Sign in to be the first to comment on Java Cart Password java.