Interface HashingService


  • public interface HashingService
    Support for creating a hash and validating passwords. When creating a hash from a string or char[], a random salt will be generated and given with the hash through a Hash object.
    • Method Detail

      • createHash

        Hash createHash​(String toHash)
        Creates a hash from a string.
        Parameters:
        toHash - the String to hash.
        Returns:
        a Hash giving the hash of the String and the Salt used.
      • createHash

        Hash createHash​(char[] toHash)
        Creates a hash from a char[]. This method can be convenient as passwords are often represented in java as char[].
        Parameters:
        toHash - the char[] to hash.
        Returns:
        a Hash giving the hash of the char[] and the Salt used.
      • validatePassword

        boolean validatePassword​(char[] password,
                                 Hash correctHash)
        Validates a password using a hash.
        Parameters:
        password - the password to check.
        correctHash - the hash of the valid password.
        Returns:
        true if the password is correct, false if not.
      • validatePassword

        boolean validatePassword​(String password,
                                 Hash correctHash)
        Validates a password using a hash.
        Parameters:
        password - the password to check.
        correctHash - the hash of the valid password.
        Returns:
        true if the password is correct, false if not.