Class BCryptHashFunction


public class BCryptHashFunction extends HashFunction
A cryptograhpic hash function implemented using BCrypt. This hash function can be used for creating password hashes.
  • Constructor Details

    • BCryptHashFunction

      public BCryptHashFunction()
  • Method Details

    • getName

      public String getName()
      Returns the name for this hash function. Returns "BCrypt".
      Specified by:
      getName in class HashFunction
    • compute

      public String compute(String msg, String salt)
      Description copied from class: HashFunction
      Computes the hash of a message + salt.

      The message is usually an ASCII or UTF-8 string.

      The salt and the computed hash are encoded in printable characters. This is usually ASCII-encoded or could be Base64-encoded.

      Specified by:
      compute in class HashFunction
    • verify

      public boolean verify(String msg, String salt, String hash)
      Description copied from class: HashFunction
      Verifies a message with the salted hash.

      The base implementation will recompute the hash of the message with the given salt, and compare it to the hash.

      Some methods however store the salt and additional settings in the hash, and this information is thus needed to verify the message hash.

      verify in class HashFunction
    • main

      public static void main(String[] args)