feat(加密解密): 完善加密管理与保存继承
build.yaml / build (push) Successful in 45s

This commit is contained in:
xiaoqidun committed 2026-09-30 01:35:24 +08:00
1 parent d56a84f92a
commit b0b194895a
8 files changed
+263 -109

No files matched your search

+15 -6
View File
@@ -76,11 +76,13 @@ type EncryptionOptions struct {
}
// EncryptionInfo 不含敏感凭据的文档加密信息
// PolicyRequired表示无法继承原策略,保存前需显式设置加密方式
type EncryptionInfo struct {
Encrypted bool
Method string
Users []string
Layers int
Encrypted bool
Method string
Users []string
Layers int
PolicyRequired bool
}
// encryptionState 保存解密来源与可继承的输出策略
@@ -113,10 +115,17 @@ func WithCryptoProvider(provider CryptoProvider) ReaderOption {
// Encryption 获取文档加密状态,不暴露口令或私钥
// 返回: EncryptionInfo 加密状态
func (r *Reader) Encryption() EncryptionInfo {
if r.encryption == nil {
return r.encryption.summary()
}
// summary 复制不含凭据的加密状态
// 返回: EncryptionInfo 加密状态
func (s *encryptionState) summary() EncryptionInfo {
if s == nil {
return EncryptionInfo{}
}
info := r.encryption.info
info := s.info
info.PolicyRequired = s.options == nil
info.Users = append([]string(nil), info.Users...)
return info
}