Package eu.webtoolkit.jwt.auth
Class BCryptHashFunction
- java.lang.Object
-
- eu.webtoolkit.jwt.auth.HashFunction
-
- eu.webtoolkit.jwt.auth.BCryptHashFunction
-
public class BCryptHashFunction extends HashFunction
A cryptograhpic hash function implemented using BCrypt. This hash function can be used for creating password hashes.
-
-
Constructor Summary
Constructors Constructor Description BCryptHashFunction()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Stringcompute(java.lang.String msg, java.lang.String salt)Computes the hash of a message + salt.java.lang.StringgetName()Returns the name for this hash function.static voidmain(java.lang.String[] args)booleanverify(java.lang.String msg, java.lang.String salt, java.lang.String hash)Verifies a message with the salted hash.
-
-
-
Method Detail
-
getName
public java.lang.String getName()
Returns the name for this hash function. Returns "BCrypt".- Specified by:
getNamein classHashFunction
-
compute
public java.lang.String compute(java.lang.String msg, java.lang.String salt)Description copied from class:HashFunctionComputes the hash of a message + salt.The message is usually an ASCII or UTF-8 string.
The
saltand the computed hash are encoded in printable characters. This is usually ASCII-encoded or could be Base64-encoded.- Specified by:
computein classHashFunction
-
verify
public boolean verify(java.lang.String msg, java.lang.String salt, java.lang.String hash)Description copied from class:HashFunctionVerifies 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.- Overrides:
verifyin classHashFunction
-
main
public static void main(java.lang.String[] args)
-
-