Enum Class SymmetricAlgorithm
- All Implemented Interfaces:
Serializable, Comparable<SymmetricAlgorithm>, Constable
Symmetric encryption algorithm enumeration - 对称加密算法枚举
对称加密算法的枚举定义
Features | 主要功能:
- All supported symmetric algorithm definitions - 所有支持的对称算法定义
Usage Examples | 使用示例:
SymmetricAlgorithm alg = SymmetricAlgorithm.AES_GCM_256;
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 ConstantDescriptionAES-CBC with 128-bit key and PKCS5 paddingAES-CBC with 256-bit key and PKCS5 paddingAES-CTR with 128-bit key (Counter mode)AES-CTR with 256-bit key (Counter mode)AES-GCM with 128-bit key (Recommended AEAD)AES-GCM with 256-bit key (Recommended AEAD)ChaCha20-Poly1305 with 256-bit key (Recommended AEAD)SM4-CBC with 128-bit key and PKCS5 padding (Chinese national standard)SM4-GCM with 128-bit key (Chinese national standard AEAD) -
Method Summary
Modifier and TypeMethodDescriptionintGets the key size in bits 获取密钥大小(位)Gets the cipher transformation string 获取密码转换字符串booleanisAead()Checks if this is an AEAD algorithm 检查是否为 AEAD 算法booleanChecks if this algorithm is recommended for use 检查算法是否推荐使用static SymmetricAlgorithmReturns the enum constant of this class with the specified name.static SymmetricAlgorithm[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
AES_GCM_128
AES-GCM with 128-bit key (Recommended AEAD) -
AES_GCM_256
AES-GCM with 256-bit key (Recommended AEAD) -
AES_CBC_128
AES-CBC with 128-bit key and PKCS5 padding -
AES_CBC_256
AES-CBC with 256-bit key and PKCS5 padding -
AES_CTR_128
AES-CTR with 128-bit key (Counter mode) -
AES_CTR_256
AES-CTR with 256-bit key (Counter mode) -
CHACHA20_POLY1305
ChaCha20-Poly1305 with 256-bit key (Recommended AEAD) -
SM4_GCM
SM4-GCM with 128-bit key (Chinese national standard AEAD) -
SM4_CBC
SM4-CBC with 128-bit key and PKCS5 padding (Chinese national standard)
-
-
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
-
getTransformation
Gets the cipher transformation string 获取密码转换字符串- Returns:
- the transformation string (e.g., "AES/GCM/NoPadding")
-
getKeySize
public int getKeySize()Gets the key size in bits 获取密钥大小(位)- Returns:
- the key size
-
isAead
public boolean isAead()Checks if this is an AEAD algorithm 检查是否为 AEAD 算法AEAD algorithms provide both confidentiality and authenticity
- Returns:
- true if this is an AEAD algorithm, false otherwise
-
isRecommended
public boolean isRecommended()Checks if this algorithm is recommended for use 检查算法是否推荐使用AEAD algorithms are generally recommended for modern applications
- Returns:
- true if the algorithm is recommended, false otherwise
-