crypto

package
v1.5.11 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildQueryLike added in v1.3.3

func BuildQueryLike(ctx context.Context, tx *sql.Tx, data any, cond string) (str string, err error)

func GenerateSQLConditions added in v1.3.3

func GenerateSQLConditions(data any) (strs []string)

func QueryContext added in v1.3.3

func QueryContext[D Database, T Entity](ctx context.Context, db D, baseQuery string, queryParams []interface{}, iOptInitFunc func(*T), IOptInitValue func(T)) (t []T, err error)

func QueryLike added in v1.3.3

func QueryLike[T Entity](ctx context.Context, basQuery string, tx *sql.Tx, iOptionalFilter func(*ILikeParams), iOptInitFunc func(*T)) (t []T, err error)

func StructToInterfaceScan added in v1.3.6

func StructToInterfaceScan(v interface{}) []interface{}

Types

type AesKeySize

type AesKeySize int
const (
	Aes128KeySize AesKeySize = 16

	Aes192KeySize AesKeySize = 24

	Aes256KeySize AesKeySize = 32
)

type Crypto

type Crypto struct {
	AESKey  *string `env:"AES_KEY,expand" json:"aes_key"`
	HMACKey *string `env:"HMAC_KEY,expand" json:"hmac_key"`

	Host *string `env:"HEAP_DB_HOST" envDefault:"localhost" json:"db_host"`
	Port *string `env:"HEAP_DB_PORT" envDefault:"5432" json:"db_port"`
	User *string `env:"HEAP_DB_USER" envDefault:"user" json:"db_user"`
	Pass *string `env:"HEAP_DB_PASS" envDefault:"password" json:"db_pass"`
	Name *string `env:"HEAP_DB_NAME" envDefault:"dbname" json:"db_name"`
	// contains filtered or unexported fields
}

func New

func New(keySize AesKeySize, opts ...Opts) (c *Crypto, err error)

func (*Crypto) AESFunc

func (c *Crypto) AESFunc() func() (core.PrimitiveAES, error)

func (*Crypto) AESWithKeyFunc added in v1.5.11

func (c *Crypto) AESWithKeyFunc(key []byte) func() (core.PrimitiveAES, error)

func (*Crypto) BindHeap added in v1.3.4

func (c *Crypto) BindHeap(entity any) (err error)

func (*Crypto) Decrypt

func (c *Crypto) Decrypt(alg aesx.AesAlg) aesx.AES[string, core.PrimitiveAES]

func (*Crypto) Encrypt

func (c *Crypto) Encrypt(data string, alg aesx.AesAlg) aesx.AES[string, core.PrimitiveAES]

func (*Crypto) HMACFunc

func (c *Crypto) HMACFunc() func() (core.PrimitiveHMAC, error)

func (*Crypto) Hash

func (c *Crypto) Hash(data string) string

func (*Crypto) HashString added in v1.5.7

func (c *Crypto) HashString(data string) string

func (*Crypto) InitHeapDatabase added in v1.3.4

func (c *Crypto) InitHeapDatabase() (*sql.DB, error)

func (*Crypto) SearchContents added in v1.3.8

func (c *Crypto) SearchContents(ctx context.Context, table string, args func(*FindTextHeapByContentParams)) (heaps []string, err error)

type Database added in v1.3.3

type Database interface {
	QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
}

type Entity added in v1.3.3

type Entity interface{}

type FindTextHeapByContentParams added in v1.3.3

type FindTextHeapByContentParams struct {
	Content string
}

type FindTextHeapByHashParams added in v1.3.3

type FindTextHeapByHashParams struct {
	Hash string
}

type FindTextHeapRow added in v1.3.3

type FindTextHeapRow struct {
	ID      uuid.UUID
	Content string
	Hash    string
}

type ILikeParams added in v1.3.3

type ILikeParams struct {
	ColumnHeap string
	Hash       []string
}

type Opts added in v1.2.3

type Opts func(*Crypto) error

func WithInitHeapConnection added in v1.3.9

func WithInitHeapConnection() Opts

type ResultHeap added in v1.3.4

type ResultHeap struct {
	Column string `json:"column"`
	Value  string `json:"value"`
}

type TextHeap added in v1.3.3

type TextHeap struct {
	Content string
	Type    string
	Hash    string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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