Enum Class Hash.Algorithm

java.lang.Object
java.lang.Enum<Hash.Algorithm>
org.htmlunit.csp.value.Hash.Algorithm
All Implemented Interfaces:
Serializable, Comparable<Hash.Algorithm>, Constable
Enclosing class:
Hash

public static enum Hash.Algorithm extends Enum<Hash.Algorithm>
Enumerates the hash algorithms supported by CSP hash-sources.

Each constant carries the lowercase algorithm name used in the CSP grammar and the expected Base64-encoded output length for validation purposes.

  • Enum Constant Details

    • SHA256

      public static final Hash.Algorithm SHA256
      SHA-256 algorithm (sha256), producing a 44-character Base64 digest.
    • SHA384

      public static final Hash.Algorithm SHA384
      SHA-384 algorithm (sha384), producing a 64-character Base64 digest.
    • SHA512

      public static final Hash.Algorithm SHA512
      SHA-512 algorithm (sha512), producing an 88-character Base64 digest.
  • Method Details

    • values

      public static Hash.Algorithm[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static Hash.Algorithm valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • getLength

      public int getLength()
      Returns the expected length of the Base64-encoded digest for this algorithm.
      Returns:
      the expected Base64 string length
    • toString

      public String toString()
      Returns the lowercase algorithm name as used in the CSP grammar (e.g. "sha256").
      Overrides:
      toString in class Enum<Hash.Algorithm>
      Returns:
      the algorithm name string