Class VersionedCipher.Builder
java.lang.Object
cloud.opencode.base.crypto.versioned.VersionedCipher.Builder
- Enclosing class:
VersionedCipher
Builder for constructing
VersionedCipher instances.
用于构建 VersionedCipher 实例的构建器。- Since:
- JDK 25, opencode-base-crypto V1.0.3
- Author:
- Leon Soo www.LeonSoo.com
-
Method Summary
Modifier and TypeMethodDescriptionaddVersion(int version, AeadCipher cipher) Registers a cipher for the given version number.build()Builds an immutable VersionedCipher from the current builder state.currentVersion(int version) Sets the current (active) version used for encryption.
-
Method Details
-
addVersion
Registers a cipher for the given version number. 为给定版本号注册加密器。- Parameters:
version- the version number (0-255) | 版本号(0-255)cipher- the AEAD cipher for this version | 此版本的 AEAD 加密器- Returns:
- this builder | 当前构建器
- Throws:
IllegalArgumentException- if the version is already registered or out of range | 当版本已注册或超出范围时抛出
-
currentVersion
Sets the current (active) version used for encryption. 设置用于加密的当前(活动)版本。- Parameters:
version- the version to use for encryption (must be already registered) | 用于加密的版本(必须已注册)- Returns:
- this builder | 当前构建器
- Throws:
IllegalArgumentException- if the version has not been registered | 当版本未注册时抛出
-
build
Builds an immutable VersionedCipher from the current builder state. 从当前构建器状态构建不可变的 VersionedCipher。- Returns:
- a new VersionedCipher instance | 新的 VersionedCipher 实例
- Throws:
IllegalStateException- if no versions registered or currentVersion not set | 当未注册版本或未设置当前版本时抛出
-