java.lang.Object
io.getlime.security.powerauth.crypto.server.util.DataDigest

public class DataDigest extends Object
This is a helper class that provides utility methods for computing various data digests.
Author:
Petr Dvorak, petr@wultra.com
  • Constructor Details

    • DataDigest

      public DataDigest()
      Initializes the data digest instance that produces digest of length 8.
    • DataDigest

      public DataDigest(int length) throws GenericCryptoException
      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 uses int, 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

      public DataDigest.Result generateDigest(List<String> items)
      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.