AS AgentScopeAPI 手册 / API Reference

TokenEncryption

public class TokenEncryption
源码Source io/agentscope/harness/coding/metadata/TokenEncryption.java:49–118

令牌 Encryption,承载智能体的部署、调度与服务化运行。位于 io.agentscope.harness.coding.metadata 包。核心成员包括 encrypt、decrypt、TokenEncryption。

Token encryption/decryption using Google Tink AEAD.

Used to store GitHub tokens encrypted at rest in SqliteBaseStore.

Key management

The keyset JSON is loaded from:

  • TOKEN_ENC_KEYSET_PATH env var (path to JSON file)

  • TOKEN_ENC_KEYSET env var (inline base64-encoded JSON)

Generate a new keyset with:


tinkey create-keyset --key-template AES256_GCM --out keyset.json

构造器摘要Constructor Summary

构造器Constructor说明Description
public TokenEncryption() throws GeneralSecurityException
初始化 `TokenEncryption` 实例。
Creates a new instance.

方法摘要Method Summary

方法Method说明Description
public String encrypt(String plaintext) throws GeneralSecurityException
设置该参数。
Encrypts a plaintext token.
public String decrypt(String ciphertext) throws GeneralSecurityException
设置该参数。
Decrypts a ciphertext token.

构造器详情Constructor Detail

TokenEncryption

public TokenEncryption() throws GeneralSecurityException

初始化 TokenEncryption 实例。

Creates a new instance.

抛出Throws
  • GeneralSecurityException 可能抛出 `GeneralSecurityException`。Thrown when the operation cannot be completed.
源码Source io/agentscope/harness/coding/metadata/TokenEncryption.java:53–56

方法详情Method Detail

encrypt

public String encrypt(String plaintext) throws GeneralSecurityException

设置该参数。

Encrypts a plaintext token.

参数Parameters
名称Name类型Type说明Description
plaintextStringplaintext(类型 `String`)。token to encrypt
返回Returns String
返回字符串结果。base64url-encoded ciphertext
抛出Throws
  • GeneralSecurityException 可能抛出 `GeneralSecurityException`。Thrown when the operation cannot be completed.
源码Source io/agentscope/harness/coding/metadata/TokenEncryption.java:64–67

decrypt

public String decrypt(String ciphertext) throws GeneralSecurityException

设置该参数。

Decrypts a ciphertext token.

参数Parameters
名称Name类型Type说明Description
ciphertextStringciphertext(类型 `String`)。base64url-encoded ciphertext (from `#encrypt`)
返回Returns String
返回字符串结果。plaintext token
抛出Throws
  • GeneralSecurityException 可能抛出 `GeneralSecurityException`。Thrown when the operation cannot be completed.
源码Source io/agentscope/harness/coding/metadata/TokenEncryption.java:75–78
基于官方固定版本源码静态生成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.