Interface HashSpi

All Known Implementing Classes:
SimpleHashProvider

public interface HashSpi
Service Provider Interface for password hashing algorithms.

Apache Shiro will load algorithm implementations based on the method getImplementedAlgorithms(). Loaded providers are expected to return a suitable hash implementation.

Modern kdf-based hash implementations can extend the AbstractCryptHash class.

Since:
2.0
  • Method Details

    • getImplementedAlgorithms

      Set<String> getImplementedAlgorithms()
      A list of algorithms recognized by this implementation.

      Example values are argon2id and argon2i for the Argon2 service provider and 2y and 2a for the BCrypt service provider.

      Returns:
      a set of recognized algorithms.
    • fromString

      Hash fromString(String format)
      Creates a Hash instance from the given format string recognized by this provider.

      There is no global format which this provider must accept. Each provider can define their own format, but they are usually based on the crypt(3) formats used in /etc/shadow files.

      Implementations should overwrite this javadoc to add examples of the accepted formats.

      Parameters:
      format - the format string to be parsed by this implementation.
      Returns:
      a class extending Hash.
    • newHashFactory

      HashSpi.HashFactory newHashFactory(Random random)
      A factory class for the hash of the type <T>.

      Implementations are highly encouraged to use the given random parameter as source of random bytes (e.g. for seeds).

      Parameters:
      random - a source of Random, usually SecureRandom.
      Returns:
      a factory class for creating instances of <T>.