Class DataDigest
java.lang.Object
io.getlime.security.powerauth.crypto.server.util.DataDigest
This is a helper class that provides utility methods for computing various data digests.
- Author:
- Petr Dvorak, petr@wultra.com
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionInitializes the data digest instance that produces digest of length 8.DataDigest(int length) Initializes the data digest instance that produces digest of specified length. -
Method Summary
Modifier and TypeMethodDescriptiongenerateDigest(List<String> items) Data digest of the list with string elements.
-
Constructor Details
-
DataDigest
public DataDigest()Initializes the data digest instance that produces digest of length 8. -
DataDigest
Initializes the data digest instance that produces digest of specified length. The length must be between 4 and 9. The digest cannot be shorter than 4 due to lack of entropy in shorter codes. The digest cannot be longer than 9 digits since the internal implementation usesint, with a 64 bit range.- Parameters:
length- Length of the resulting digest.- Throws:
GenericCryptoException- In case the length is not in the allowed range - between 4 and 9 digits.
-
-
Method Details
-
generateDigest
Data digest of the list with string elements. Data is first normalized (items concatenated by '&' character), then a random key is generated and hash (HMAC-SHA256) is computed. Finally, the resulting MAC is decimalized to the signature of a length 8 numeric digits.In case the digest could not be computed, null value is returned.
- Parameters:
items- Items to be serialized into digest.- Returns:
- Digest fo provided data, including seed used to compute that digest.
-