Enum Class DigestAlgorithm

java.lang.Object
java.lang.Enum<DigestAlgorithm>
cloud.opencode.base.crypto.enums.DigestAlgorithm
All Implemented Interfaces:
Serializable, Comparable<DigestAlgorithm>, Constable

public enum DigestAlgorithm extends Enum<DigestAlgorithm>
Digest algorithm enumeration for cryptographic hash functions - 摘要算法枚举 加密哈希函数的摘要算法枚举

Features | 主要功能:

  • All supported digest algorithm definitions - 所有支持的摘要算法定义

Usage Examples | 使用示例:

DigestAlgorithm alg = DigestAlgorithm.SHA_256;
String name = alg.getAlgorithmName();

Security | 安全性:

  • Thread-safe: Yes - 线程安全: 是
  • Null-safe: Partial - 空值安全: 部分

Performance | 性能特性:

  • Time complexity: O(1) - 时间复杂度: O(1)
  • Space complexity: O(1) - 空间复杂度: O(1)
Since:
JDK 25, opencode-base-crypto V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from class Enum

    Enum.EnumDesc<E>
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    BLAKE2B-256 algorithm - 256-bit digest
    BLAKE2B-512 algorithm - 512-bit digest
    BLAKE3 algorithm - 256-bit digest
    Deprecated.
    MD5 is cryptographically broken and should not be used for security purposes.
    Deprecated.
    SHA-1 is cryptographically weak and should not be used for security purposes.
    SHA-224 algorithm - 224-bit digest
    SHA-256 algorithm - 256-bit digest (Recommended)
    SHA3-224 algorithm - 224-bit digest
    SHA3-256 algorithm - 256-bit digest (Recommended)
    SHA3-384 algorithm - 384-bit digest
    SHA3-512 algorithm - 512-bit digest
    SHA-384 algorithm - 384-bit digest
    SHA-512 algorithm - 512-bit digest
    SM3 algorithm - 256-bit digest (Chinese national standard)
  • Method Summary

    Modifier and Type
    Method
    Description
    Gets the standard algorithm name 获取标准算法名称
    int
    Gets the digest length in bits 获取摘要长度(位)
    boolean
    Checks if the algorithm is considered secure 检查算法是否被认为是安全的
    Returns the enum constant of this class with the specified name.
    Returns an array containing the constants of this enum class, in the order they are declared.

    Methods inherited from class Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • MD5

      @Deprecated(since="1.0.0", forRemoval=false) public static final DigestAlgorithm MD5
      Deprecated.
      MD5 is cryptographically broken and should not be used for security purposes. Use SHA-256 or SHA3-256 instead.
      MD5 algorithm - 128-bit digest (Not recommended for security)
    • SHA1

      @Deprecated(since="1.0.0", forRemoval=false) public static final DigestAlgorithm SHA1
      Deprecated.
      SHA-1 is cryptographically weak and should not be used for security purposes. Use SHA-256 or SHA3-256 instead.
      SHA-1 algorithm - 160-bit digest (Not recommended for security)
    • SHA224

      public static final DigestAlgorithm SHA224
      SHA-224 algorithm - 224-bit digest
    • SHA256

      public static final DigestAlgorithm SHA256
      SHA-256 algorithm - 256-bit digest (Recommended)
    • SHA384

      public static final DigestAlgorithm SHA384
      SHA-384 algorithm - 384-bit digest
    • SHA512

      public static final DigestAlgorithm SHA512
      SHA-512 algorithm - 512-bit digest
    • SHA3_224

      public static final DigestAlgorithm SHA3_224
      SHA3-224 algorithm - 224-bit digest
    • SHA3_256

      public static final DigestAlgorithm SHA3_256
      SHA3-256 algorithm - 256-bit digest (Recommended)
    • SHA3_384

      public static final DigestAlgorithm SHA3_384
      SHA3-384 algorithm - 384-bit digest
    • SHA3_512

      public static final DigestAlgorithm SHA3_512
      SHA3-512 algorithm - 512-bit digest
    • SM3

      public static final DigestAlgorithm SM3
      SM3 algorithm - 256-bit digest (Chinese national standard)
    • BLAKE2B_256

      public static final DigestAlgorithm BLAKE2B_256
      BLAKE2B-256 algorithm - 256-bit digest
    • BLAKE2B_512

      public static final DigestAlgorithm BLAKE2B_512
      BLAKE2B-512 algorithm - 512-bit digest
    • BLAKE3

      public static final DigestAlgorithm BLAKE3
      BLAKE3 algorithm - 256-bit digest
  • Method Details

    • values

      public static DigestAlgorithm[] 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 DigestAlgorithm 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
    • getAlgorithmName

      public String getAlgorithmName()
      Gets the standard algorithm name 获取标准算法名称
      Returns:
      the algorithm name
    • getDigestLength

      public int getDigestLength()
      Gets the digest length in bits 获取摘要长度(位)
      Returns:
      the digest length
    • isSecure

      public boolean isSecure()
      Checks if the algorithm is considered secure 检查算法是否被认为是安全的

      MD5 and SHA-1 are considered insecure due to collision vulnerabilities

      Returns:
      true if the algorithm is secure, false otherwise