Class Hasher
java.lang.Object
com.github.natche.gravatarjavaclient.utils.Hasher
A class used for hashing inputs using certain algorithms.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final HasherA shared hasher instance using the SHA256 algorithm. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns whether the provided object equals this object.static HasherfromAlgorithm(String algorithm) Returns a new Hasher instance using the provided algorithm.Hashes the provided input using the encapsulated algorithm.inthashCode()Returns a hash code of this object.toString()Returns a string representation of this object.
-
Field Details
-
SHA256_HASHER
A shared hasher instance using the SHA256 algorithm.
-
-
Method Details
-
fromAlgorithm
Returns a new Hasher instance using the provided algorithm.- Parameters:
algorithm- the algorithm- Returns:
- a new Hasher instance using the provided algorithm
- Throws:
NullPointerException- if the provided algorithm is nullIllegalArgumentException- if the provided algorithm is empty
-
hash
Hashes the provided input using the encapsulated algorithm. Note: prior to hashing, the input is trimmed and converted to lower case.- Parameters:
input- the input to hash- Returns:
- the hashed input
- Throws:
NullPointerException- if the provided input is null
-
equals
Returns whether the provided object equals this object. -
hashCode
public int hashCode()Returns a hash code of this object. -
toString
Returns a string representation of this object.
-