Documentation
¶
Index ¶
- func GCMDecrypt(aesKey []byte, nonce []byte, ciphertext []byte) (plaintext []byte, err error)
- func GCMDecryptWithNoncePrepended(aesKey []byte, ciphertext []byte) (plaintext []byte, err error)
- func GCMEncrypt(aesKey []byte, plaintext []byte) (ciphertext []byte, nonce []byte, err error)
- func GCMEncryptWithNoncePrepended(aesKey []byte, plaintext []byte) (result []byte, nonce []byte, err error)
- func GCMNonceSize() int
- func GenerateGCMNonce() ([]byte, error)
- func ParseIPListFromStr(value string, delimiter string) []net.IP
- func SplitStrTrimList(value string, delimiter string) []string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GCMDecrypt ¶
GCMDecrypt 使用 AES-GCM 模式解密数据. 参数:
- aesKey: AES 密钥, 支持 16, 24 或 32 字节(对应 AES-128, AES-192, AES-256).
- nonce: 加密时生成的 nonce.
- ciphertext: 待解密的密文.
返回值:
- plaintext: 解密后的明文数据.
- error: 错误信息.
func GCMDecryptWithNoncePrepended ¶
GCMDecryptWithNoncePrepended 解密 nonce 前置的密文数据. 参数:
- aesKey: AES 密钥, 支持 16, 24 或 32 字节(对应 AES-128, AES-192, AES-256).
- ciphertext: nonce + 密文的组合数据.
返回值:
- plaintext: 解密后的明文数据.
- error: 错误信息.
func GCMEncrypt ¶
GCMEncrypt 使用 AES-GCM 模式加密数据. 参数:
- aesKey: AES 密钥, 支持 16, 24 或 32 字节(对应 AES-128, AES-192, AES-256).
- plaintext: 待加密的明文数据, 如果为 nil, 则返回 nil 密文和有效的 nonce.
返回值:
- ciphertext: 加密后的密文(不包含 nonce).
- nonce: 随机生成的 nonce(GCM 推荐 12 字节).
- error: 错误信息.
func GCMEncryptWithNoncePrepended ¶
func GCMEncryptWithNoncePrepended(aesKey []byte, plaintext []byte) (result []byte, nonce []byte, err error)
GCMEncryptWithNoncePrepended 使用 AES-GCM 模式加密数据, 并将 nonce 前置到密文中. 参数:
- aesKey: AES 密钥, 支持 16, 24 或 32 字节(对应 AES-128, AES-192, AES-256).
- plaintext: 待加密的明文数据, 如果为 nil, 则返回 nil 密文和有效的 nonce.
返回值:
- result: nonce + 密文的组合数据.
- nonce: 随机生成的 nonce.
- error: 错误信息.
func GenerateGCMNonce ¶
GenerateGCMNonce 生成一个随机的 GCM nonce. 返回值:
- nonce: 随机生成的 nonce(12 字节).
- error: 错误信息.
func ParseIPListFromStr ¶
ParseIPListFromStr 从逗号分隔的字符串解析 IP 地址列表.
func SplitStrTrimList ¶
SplitStrTrimList 将字符串按指定分隔符拆分为字符串切片,并去除每个元素的前后空格,忽略空元素。
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.