Help us shape the future of Go! Take the 2026 Go Developer Survey

encryption

package
v1.2.59 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 22, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AesGcmDecryptBase64String

func AesGcmDecryptBase64String(key, nonce []byte, ciphertext string) (string, error)

AesGcmDecryptBase64String decrypt message(base64.std.string) using AES-GCM

func AesGcmDecryptBytes

func AesGcmDecryptBytes(key, nonce, cipherBytes []byte) ([]byte, error)

AesGcmDecryptBytes Decrypt message using AES-GCM

func AesGcmEncryptBase64String

func AesGcmEncryptBase64String(key, nonce []byte, plaintext string) (string, error)

AesGcmEncryptBase64String Encrypt message from base64 string to string using AES-GCM

func AesGcmEncryptBytes

func AesGcmEncryptBytes(key, nonce, plain []byte) ([]byte, error)

AesGcmEncryptBytes encrypt message using AES-GCM

func CheckIsModeAICC

func CheckIsModeAICC() bool

func DecryptChatResponse

func DecryptChatResponse(keyNonce []byte, response model.Response) error

func DecryptChatStreamResponse

func DecryptChatStreamResponse(keyNonce []byte, response model.ChatCompletionStreamResponse) error

func ECDHMarshalBinary

func ECDHMarshalBinary(pub *ecdsa.PublicKey) []byte

func EncryptChatRequest

func EncryptChatRequest(ctx context.Context, keyNonce []byte, request model.CreateChatCompletionRequest) error

func EncryptURL

func EncryptURL(urlString string, fn func(text string) (string, error)) (string, error)

func GenerateKey

func GenerateKey(curve elliptic.Curve) (*ecdsa.PrivateKey, *ecdsa.PublicKey, error)

GenerateKey is the constructor for Private-Public key pair

func GetCertInfo

func GetCertInfo(certPem string) (string, string, int64)

func LoadLocalCertificate

func LoadLocalCertificate(model string) (string, error)

func MarshalBinary

func MarshalBinary(pub *ecdsa.PublicKey) []byte

func NewHKDF

func NewHKDF(hash func() hash.Hash, secret, salt, info []byte) io.Reader

NewHKDF creates a new HKDF reader for extracting and expanding keys

func ProcessChatCompletionMessageContent

func ProcessChatCompletionMessageContent(content *model.ChatCompletionMessageContent, fn func(text string) (string, error)) error

func ProcessChatCompletionRequest

func ProcessChatCompletionRequest(ctx context.Context, msgs []*model.ChatCompletionMessage, fn func(text string) (string, error)) error

ProcessChatCompletionRequest process chat completion request

func ReadCertFromBytes

func ReadCertFromBytes(pemBytes []byte) (*x509.Certificate, error)

func ReadCertFromString

func ReadCertFromString(pemString string) (*x509.Certificate, error)

func ReadEcdsaPrivKeyFromBytes

func ReadEcdsaPrivKeyFromBytes(pemBytes []byte) (*ecdsa.PrivateKey, error)

func ReadEcdsaPrivKeyFromString

func ReadEcdsaPrivKeyFromString(key string) (*ecdsa.PrivateKey, error)

func SaveToLocalCertificate

func SaveToLocalCertificate(model, certPem string) error

func StringInSlice

func StringInSlice(str string, list []string) bool

Types

type KeyAgreementClient

type KeyAgreementClient struct {
	// contains filtered or unexported fields
}

func NewP256KeyAgreementClient

func NewP256KeyAgreementClient(pemString string) (*KeyAgreementClient, error)

NewP256KeyAgreementClient Load cert and extract public key

func (*KeyAgreementClient) GenerateECIESKeyPair

func (k *KeyAgreementClient) GenerateECIESKeyPair() ([]byte, string, error)

GenerateECIESKeyPair generate ECIES key pair and return the tuple (keyNonce, session token, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL