AS AgentScopeAPI 手册 / API Reference

DashScopeEncryptionUtils

public final class DashScopeEncryptionUtils
源码Source io/agentscope/extensions/model/dashscope/DashScopeEncryptionUtils.java:42–181

DashScope Encryption Utils,与模型服务通信并返回生成或向量化结果。位于 io.agentscope.extensions.model.dashscope 包。核心成员包括 generateAesSecretKey、generateIv、encryptWithAes、decryptWithAes、encryptAesKeyWithRsa。

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.

嵌套类摘要Nested Class Summary

类Class类型Kind说明Description
EncryptionException类class
Encryption 异常,表示执行过程中的错误。
Exception thrown when encryption/decryption operations fail.

方法摘要Method Summary

方法Method说明Description
public static SecretKey generateAesSecretKey()
static
返回 `generateAesSecretKey` 结果。
Generate a new AES secret key for encryption.
public static byte[] generateIv()
static
返回 `generateIv` 结果。
Generate a unique initialization vector (IV) for AES-GCM encryption.
public static String encryptWithAes(SecretKey secretKey, byte[] iv, String plaintext)
static
执行 `encryptWithAes` 方法。
Encrypt data using AES-GCM.
public static String decryptWithAes(SecretKey secretKey, byte[] iv, String encryptedData)
static
执行 `decryptWithAes` 方法。
Decrypt data using AES-GCM.
public static String encryptAesKeyWithRsa(SecretKey aesSecretKey, String publicKeyBase64)
static
执行 `encryptAesKeyWithRsa` 方法。
Encrypt an AES secret key using RSA public key.

方法详情Method Detail

generateAesSecretKey

public static SecretKey generateAesSecretKey()
static

返回 generateAesSecretKey 结果。

Generate a new AES secret key for encryption.

返回Returns SecretKey
一种新的AES-256 密钥密钥。a new AES-256 secret key
抛出Throws
源码Source io/agentscope/extensions/model/dashscope/DashScopeEncryptionUtils.java:63–72

generateIv

public static byte[] generateIv()
static

返回 generateIv 结果。

Generate a unique initialization vector (IV) for AES-GCM encryption.

返回Returns byte[]
返回byte[]。a random 12-byte IV
源码Source io/agentscope/extensions/model/dashscope/DashScopeEncryptionUtils.java:79–84

encryptWithAes

public static String encryptWithAes(SecretKey secretKey, byte[] iv, String plaintext)
static

执行 encryptWithAes 方法。

Encrypt data using AES-GCM.

参数Parameters
名称Name类型Type说明Description
secretKeySecretKeyAES 密钥密钥。the AES secret key
ivbyte[]iv(类型 `byte[]`)。the initialization vector
plaintextStringplaintext(类型 `String`)。the plaintext data to encrypt
返回Returns String
返回字符串结果。Base64-encoded encrypted data
抛出Throws
源码Source io/agentscope/extensions/model/dashscope/DashScopeEncryptionUtils.java:95–111

decryptWithAes

public static String decryptWithAes(SecretKey secretKey, byte[] iv, String encryptedData)
static

执行 decryptWithAes 方法。

Decrypt data using AES-GCM.

参数Parameters
名称Name类型Type说明Description
secretKeySecretKeyAES 密钥密钥。the AES secret key
ivbyte[]iv(类型 `byte[]`)。the initialization vector
encryptedDataString已加密数据(类型 `String`)。Base64-encoded encrypted data
返回Returns String
返回字符串结果。the decrypted plaintext
抛出Throws
源码Source io/agentscope/extensions/model/dashscope/DashScopeEncryptionUtils.java:122–138

encryptAesKeyWithRsa

public static String encryptAesKeyWithRsa(SecretKey aesSecretKey, String publicKeyBase64)
static

执行 encryptAesKeyWithRsa 方法。

Encrypt an AES secret key using RSA public key.

参数Parameters
名称Name类型Type说明Description
aesSecretKeySecretKeyaes 密钥键(类型 `SecretKey`)。the AES secret key to encrypt
publicKeyBase64Stringpublic 键基类 64(类型 `String`)。Base64-encoded RSA public key
返回Returns String
返回字符串结果。Base64-encoded encrypted AES key
抛出Throws
源码Source io/agentscope/extensions/model/dashscope/DashScopeEncryptionUtils.java:148–167

嵌套类详情Nested Class Detail

EncryptionException

public static class EncryptionException extends RuntimeException

Encryption 异常,表示执行过程中的错误。位于 io.agentscope.extensions.model.dashscope 包,继承自 RuntimeException。核心成员包括 EncryptionException。

Exception thrown when encryption/decryption operations fail.

基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.