package cnrg.itx.ds;

/**
 * This class provides an encapsulation to store user's password information.
 */
public class Password
{
	// private data member
	private int m_passwd = -1;

	/**
	 * Constructor for String
	 * @param strPW input password string
	 */
	public Password(String strPW){
		m_passwd = strPW.hashCode();
	}
	
	/**
	 * Verify against a given password object
	 * @param inputPW input password
	 * @return true if verified successfully; false otherwise
	 */
	public boolean verified(Password inputPW){
		return ( m_passwd == Integer.parseInt(inputPW.toString()) );
	}
	
	/**
	 * Verify against a given authenticated record object
	 * @param inputSEC input authenticated record object
	 * @return true if verified successfully; false otherwise
	 */
	boolean verified(AuthenticateRecord inputSEC){
		return ( m_passwd == Integer.parseInt(inputSEC.getKey()) );
	}
	
	public String toString() {
		return String.valueOf(m_passwd);
	}
}
