Class MessageDigestAlgorithm

    • Constructor Detail

      • MessageDigestAlgorithm

        public MessageDigestAlgorithm​(String digest,
                                      int saltLength,
                                      int iterations)
        Parameters:
        digest - an algorithm name suitable for MessageDigest.getInstance(String).
    • Method Detail

      • hash

        public byte[] hash​(byte[] plainText)
        Description copied from interface: Hash.Algorithm
        Returns a hash for the given plain text. The result is not required to be deterministic - this means, multiple calls for the same plain text do not have to return the same hash. This is especially true for salted hashes.
        Specified by:
        hash in interface Hash.Algorithm
        Parameters:
        plainText - the text to be hashed. Is never null.
        Returns:
        the hash of plainText. Must never return null.
      • check

        public boolean check​(byte[] plainText,
                             byte[] hash)
        Description copied from interface: Hash.Algorithm
        Returns whether the given plain text matches the given hash.
        Specified by:
        check in interface Hash.Algorithm
        Parameters:
        plainText - the text to be hashed. Is never null.
        hash - the hash of plainText. Is never null.
      • compatibleTo

        public boolean compatibleTo​(Hash.Algorithm other)
        Description copied from interface: Hash.Algorithm
        Returns whether this algorithm can consistently check hash values created by the given algorithm.
        Specified by:
        compatibleTo in interface Hash.Algorithm
      • getSaltLength

        public int getSaltLength()
      • getIterations

        public int getIterations()