org.clazzes.util.sec
Interface PasswordHasher

All Known Implementing Classes:
CryptPasswordHasher, PlainPasswordHasher, SSHA1PasswordHasher

public interface PasswordHasher

The password hasher interface, to allow maximum flexibility


Method Summary
 boolean checkPassword(java.lang.String cleartext, java.lang.String hashed)
          Checks if the given cleartext password conforms to the given hashed representation.
 java.lang.String getAlgorithmName()
           
 int getSaltLength()
           
 java.lang.String hashPassword(java.lang.String cleartext)
          Hashes the given password using a random salt.
 java.lang.String hashPassword(java.lang.String cleartext, java.lang.String salt)
          Hashes the given password using the given salt.
 

Method Detail

hashPassword

java.lang.String hashPassword(java.lang.String cleartext)
Hashes the given password using a random salt.

Parameters:
cleartext - Password to hash.
Returns:
the hashed i.e. encrypted password. includes the algorithm prefix.

hashPassword

java.lang.String hashPassword(java.lang.String cleartext,
                              java.lang.String salt)
Hashes the given password using the given salt.

Parameters:
cleartext - Password to hash.
salt - the salt to use.
Returns:
the hashed i.e. encrypted password. includes the algorithm prefix.

checkPassword

boolean checkPassword(java.lang.String cleartext,
                      java.lang.String hashed)
Checks if the given cleartext password conforms to the given hashed representation.

Parameters:
cleartext - cleartext password to check.
hashed - hashed correct password to check against. may include the algorithm prefix.
Returns:
true if the password seems correct.

getAlgorithmName

java.lang.String getAlgorithmName()
Returns:
the name (key) of the algorithm implemented by this hasher, as used in the algorithm prefix of hashed passwords.

getSaltLength

int getSaltLength()
Returns:
the (default resp. relevant) salt length for the hash algorithm


Copyright © 2010. All Rights Reserved.