Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Decrypt ¶
Decrypt decodes base64 string and decrypts to plaintext. Expects format: base64(nonce | ciphertext | authtag)
func DiscardGeneratedKey ¶
func DiscardGeneratedKey() error
DiscardGeneratedKey 删除本次启动新生成的密钥文件并停用它。启动检查发现库里已有旧密文时调用: 新密钥解不开旧数据,留着它,下次启动就会被当成正常密钥使用。
func Encrypt ¶
Encrypt encrypts plaintext and returns base64-encoded "nonce|ciphertext|authtag" All three components are packed into the base64 string for transport.
func KeyStatus ¶
KeyStatus 报告启动时密钥的来源,供运行时初始化做安全检查: path 是密钥文件路径(用 PT_TOOLS_SECRET_KEY 时为空),generated 表示本次启动新生成了密钥文件, err 非空表示密钥文件存在却无法使用。
func ResetForTest ¶
func ResetForTest()
ResetForTest re-reads the secret key from environment, intended for tests that need to switch the active key via t.Setenv across packages. Production code MUST NOT call this.
Types ¶
type AESGCMEncryptor ¶
type AESGCMEncryptor struct {
// contains filtered or unexported fields
}
Click to show internal directories.
Click to hide internal directories.