类 DashScopeEncryptionUtils
java.lang.Object
io.agentscope.core.model.DashScopeEncryptionUtils
Encryption utilities for secure DashScope API access.
This class provides encryption functionality for DashScope API calls using:
- AES-GCM encryption for request/response data
- RSA public key encryption for AES key exchange
This implementation follows Aliyun's encryption protocol requirements for secure cloud model inference, supporting TLS encryption and token-based authentication.
-
嵌套类概要
嵌套类修饰符和类型类说明static classException thrown when encryption/decryption operations fail. -
方法概要
修饰符和类型方法说明static StringdecryptWithAes(SecretKey secretKey, byte[] iv, String encryptedData) Decrypt data using AES-GCM.static StringencryptAesKeyWithRsa(SecretKey aesSecretKey, String publicKeyBase64) Encrypt an AES secret key using RSA public key.static StringencryptWithAes(SecretKey secretKey, byte[] iv, String plaintext) Encrypt data using AES-GCM.static SecretKeyGenerate a new AES secret key for encryption.static byte[]Generate a unique initialization vector (IV) for AES-GCM encryption.
-
方法详细资料
-
generateAesSecretKey
Generate a new AES secret key for encryption.- 返回:
- a new AES-256 secret key
- 抛出:
DashScopeEncryptionUtils.EncryptionException- if key generation fails
-
generateIv
public static byte[] generateIv()Generate a unique initialization vector (IV) for AES-GCM encryption.- 返回:
- a random 12-byte IV
-
encryptWithAes
Encrypt data using AES-GCM.- 参数:
secretKey- the AES secret keyiv- the initialization vectorplaintext- the plaintext data to encrypt- 返回:
- Base64-encoded encrypted data
- 抛出:
DashScopeEncryptionUtils.EncryptionException- if encryption fails
-
decryptWithAes
Decrypt data using AES-GCM.- 参数:
secretKey- the AES secret keyiv- the initialization vectorencryptedData- Base64-encoded encrypted data- 返回:
- the decrypted plaintext
- 抛出:
DashScopeEncryptionUtils.EncryptionException- if decryption fails
-
encryptAesKeyWithRsa
Encrypt an AES secret key using RSA public key.- 参数:
aesSecretKey- the AES secret key to encryptpublicKeyBase64- Base64-encoded RSA public key- 返回:
- Base64-encoded encrypted AES key
- 抛出:
DashScopeEncryptionUtils.EncryptionException- if encryption fails
-