Class MessageDigestAlgorithm

java.lang.Object
com.exedio.cope.pattern.MessageDigestAlgorithm
All Implemented Interfaces:
Hash.Algorithm

public final class MessageDigestAlgorithm extends Object implements Hash.Algorithm
Uses hash algorithms from MessageDigest.
Author:
Ralf Wiebicke
  • Constructor Details

  • Method Details

    • salt

      public MessageDigestAlgorithm salt(int length, SecureRandom source)
    • name

      public String name()
      Specified by:
      name in interface Hash.Algorithm
    • length

      public int length()
      Specified by:
      length in interface Hash.Algorithm
    • 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()