crypto

package module
v0.0.0-...-c163235 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DerivationKeyV1

func DerivationKeyV1(keysting string) []byte

Types

type ConfirmationLink[T any] struct {
	// Secret    []byte
	SecretGCM *SecretGCM[T]

	DefaultQueryKey string // 默认key 是 token
	// contains filtered or unexported fields
}
func NewConfirmationLink[T any](key string, UrlStr string) *ConfirmationLink[T]

func (*ConfirmationLink[T]) Decrypt

func (cl *ConfirmationLink[T]) Decrypt(ciphertext string) (*T, error)

Decrypt Encrypt加密后的数据解密 obj

func (*ConfirmationLink[T]) Encrypt

func (cl *ConfirmationLink[T]) Encrypt(obj *T) (string, error)

Encrypt golang加密后的数据

func (*ConfirmationLink[T]) Generate

func (cl *ConfirmationLink[T]) Generate(obj *T) (string, error)

Generate 序列化链接传入需求的obj

func (*ConfirmationLink[T]) GenerateWithToken

func (cl *ConfirmationLink[T]) GenerateWithToken(token string) (string, error)

GenerateWithToken 序列化url带token

type ISecretEncDec

type ISecretEncDec interface {
	EncodeToString([]byte) string
	DecodeString(string) ([]byte, error)
}

type SecretCRT

type SecretCRT[T any] struct {
	EncDec ISecretEncDec
	// contains filtered or unexported fields
}

func NewSecretCRT

func NewSecretCRT[T any](key string, iv string) *SecretCRT[T]

func (*SecretCRT[T]) Decrypt

func (s *SecretCRT[T]) Decrypt(ciphertext string) (*T, error)

func (*SecretCRT[T]) Encrypt

func (s *SecretCRT[T]) Encrypt(gobj *T) (string, error)

func (*SecretCRT[T]) UpdateDerivationKeyFunc

func (s *SecretCRT[T]) UpdateDerivationKeyFunc(kfunc func(keysting string) []byte)

type SecretGCM

type SecretGCM[T any] struct {
	EncDec ISecretEncDec
	// contains filtered or unexported fields
}

func NewSecretGCM

func NewSecretGCM[T any](key string) *SecretGCM[T]

func (*SecretGCM[T]) Decrypt

func (s *SecretGCM[T]) Decrypt(ciphertext string) (*T, error)

func (*SecretGCM[T]) Encrypt

func (s *SecretGCM[T]) Encrypt(gobj *T) (string, error)

func (*SecretGCM[T]) UpdateDerivationKeyFunc

func (s *SecretGCM[T]) UpdateDerivationKeyFunc(kfunc func(keysting string) []byte)

Jump to

Keyboard shortcuts

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