Enum Class DigestAlgorithm
- All Implemented Interfaces:
Serializable, Comparable<DigestAlgorithm>, Constable
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 ConstantsEnum ConstantDescriptionBLAKE2B-256 algorithm - 256-bit digestBLAKE2B-512 algorithm - 512-bit digestBLAKE3 algorithm - 256-bit digestDeprecated.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 digestSHA-256 algorithm - 256-bit digest (Recommended)SHA3-224 algorithm - 224-bit digestSHA3-256 algorithm - 256-bit digest (Recommended)SHA3-384 algorithm - 384-bit digestSHA3-512 algorithm - 512-bit digestSHA-384 algorithm - 384-bit digestSHA-512 algorithm - 512-bit digestSM3 algorithm - 256-bit digest (Chinese national standard) -
Method Summary
Modifier and TypeMethodDescriptionGets the standard algorithm name 获取标准算法名称intGets the digest length in bits 获取摘要长度(位)booleanisSecure()Checks if the algorithm is considered secure 检查算法是否被认为是安全的static DigestAlgorithmReturns the enum constant of this class with the specified name.static DigestAlgorithm[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
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.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
SHA-224 algorithm - 224-bit digest -
SHA256
SHA-256 algorithm - 256-bit digest (Recommended) -
SHA384
SHA-384 algorithm - 384-bit digest -
SHA512
SHA-512 algorithm - 512-bit digest -
SHA3_224
SHA3-224 algorithm - 224-bit digest -
SHA3_256
SHA3-256 algorithm - 256-bit digest (Recommended) -
SHA3_384
SHA3-384 algorithm - 384-bit digest -
SHA3_512
SHA3-512 algorithm - 512-bit digest -
SM3
SM3 algorithm - 256-bit digest (Chinese national standard) -
BLAKE2B_256
BLAKE2B-256 algorithm - 256-bit digest -
BLAKE2B_512
BLAKE2B-512 algorithm - 512-bit digest -
BLAKE3
BLAKE3 algorithm - 256-bit digest
-
-
Method Details
-
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
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 nameNullPointerException- if the argument is null
-
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
-