XuanYang-cn b6f3fd0de1
enhance: Update to the latest CipherPlugin API (#41599)
See also: #41585

Signed-off-by: yangxuan <xuan.yang@zilliz.com>
2025-04-29 14:50:50 +08:00

38 lines
890 B
Go

package message
import (
"github.com/milvus-io/milvus-proto/go-api/v2/hook"
)
// cipher is a global variable that is used to encrypt and decrypt messages.
// It should be initialized at initialization stage.
var (
cipher hook.Cipher
)
// RegisterCipher registers a cipher to be used for encrypting and decrypting messages.
// It should be called only once when the program starts and initialization stage.
func RegisterCipher(c hook.Cipher) {
if cipher != nil {
panic("cipher already registered")
}
cipher = c
}
// mustGetCipher returns the registered cipher.
func mustGetCipher() hook.Cipher {
if cipher == nil {
panic("cipher not registered")
}
return cipher
}
// CipherConfig is the configuration for cipher that is used to encrypt and decrypt messages.
type CipherConfig struct {
// EzID is the encryption zone ID.
EzID int64
// Collection ID
CollectionID int64
}