Class Md5PasswordHasher

java.lang.Object
rs.baselib.crypto.Md5PasswordHasher
All Implemented Interfaces:
ExtendedPasswordHasher, PasswordHasher

public class Md5PasswordHasher
extends java.lang.Object
implements ExtendedPasswordHasher
Uses salted MD5 hashes from Md5Crypt.
Since:
1.2.9
Author:
ralph
See Also:
Md5Crypt
  • Field Summary

    Fields 
    Modifier and Type Field Description
    static ExtendedPasswordHasher INSTANCE
    A static instance of the MD5 hasher
    static java.lang.String PREFIX
    The prefix that is present for hashes of this algorithm
  • Constructor Summary

    Constructors 
    Constructor Description
    Md5PasswordHasher()
    Constructor.
  • Method Summary

    Modifier and Type Method Description
    java.lang.String getPasswordHash​(java.lang.String plainPassword)
    Returns a hash of the given plain password.
    boolean isHash​(java.lang.String passwordHash)
    Returns whether the given hash string was produced using the implemented hashing algorithm.
    boolean testPassword​(java.lang.String plainPassword, java.lang.String passwordHash)
    Tests a plain Password whether it is the same as a previously hashed password.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • getPasswordHash

      public java.lang.String getPasswordHash​(java.lang.String plainPassword)
      Returns a hash of the given plain password.
      Specified by:
      getPasswordHash in interface PasswordHasher
      Parameters:
      plainPassword - the password to be hashed
      Returns:
      the hash of the password
    • testPassword

      public boolean testPassword​(java.lang.String plainPassword, java.lang.String passwordHash)
      Tests a plain Password whether it is the same as a previously hashed password.
      Specified by:
      testPassword in interface PasswordHasher
      Parameters:
      plainPassword - the plain password to be checked
      passwordHash - the hash of another password
      Returns:
      true when both passwords match each other
    • isHash

      public boolean isHash​(java.lang.String passwordHash)
      Returns whether the given hash string was produced using the implemented hashing algorithm.
      Specified by:
      isHash in interface ExtendedPasswordHasher
      Parameters:
      passwordHash - the hash to be checked
      Returns:
      true when this hash was produced by this password hasher (or using the same algorithm).