Enum Class CipherMode

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

public enum CipherMode extends Enum<CipherMode>
Cipher mode enumeration for symmetric encryption algorithms. 对称加密算法的加密模式枚举。

Features | 主要功能:

  • CBC, CTR, GCM, ECB mode definitions - CBC、CTR、GCM、ECB 模式定义

Usage Examples | 使用示例:

CipherMode mode = CipherMode.GCM;
String name = mode.modeName();

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:
  • Enum Constant Details

    • ECB

      @Deprecated(since="1.0.0", forRemoval=false) public static final CipherMode ECB
      Deprecated.
      ECB mode is insecure as it does not hide data patterns. Identical plaintext blocks produce identical ciphertext blocks. Use GCM (recommended), CBC, or CTR mode instead.
      Electronic Codebook mode - Not recommended for most use cases. 电子密码本模式 - 不推荐用于大多数场景。
    • CBC

      public static final CipherMode CBC
      Cipher Block Chaining mode - Requires IV. 密码块链接模式 - 需要初始化向量。
    • CTR

      public static final CipherMode CTR
      Counter mode - Requires IV. 计数器模式 - 需要初始化向量。
    • GCM

      public static final CipherMode GCM
      Galois/Counter Mode - AEAD mode, recommended. 伽罗瓦/计数器模式 - AEAD 模式,推荐使用。
    • CCM

      public static final CipherMode CCM
      Counter with CBC-MAC mode - AEAD mode. CBC-MAC计数器模式 - AEAD 模式。
  • Method Details

    • values

      public static CipherMode[] 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 CipherMode 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