crypto

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base64String

func Base64String(size int) (string, error)

func HashPassword added in v0.0.18

func HashPassword(password string) (string, error)

HashPassword hashes a plaintext password using bcrypt

func HashToken

func HashToken(token string) string

func NewRandomKey

func NewRandomKey(ctx context.Context, encryptor Encryptor, name string) (string, []byte, error)

func SHA256ForMap

func SHA256ForMap(m map[string]string) (string, error)

func VerifyPassword added in v0.0.18

func VerifyPassword(hash, password string) bool

VerifyPassword verifies a plaintext password against a bcrypt hash

func VerifySignature

func VerifySignature(key []byte, data []byte, signature string) error

Types

type AESGCMEncryptor

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

func (*AESGCMEncryptor) Decrypt

func (e *AESGCMEncryptor) Decrypt(ctx context.Context, cyphertext []byte, associatedData []byte) ([]byte, error)

func (*AESGCMEncryptor) Encrypt

func (e *AESGCMEncryptor) Encrypt(ctx context.Context, data []byte, associatedData []byte) ([]byte, error)

type Encryptor

type Encryptor interface {
	Encrypt(context.Context, []byte, []byte) ([]byte, error)
	Decrypt(context.Context, []byte, []byte) ([]byte, error)
}

func NewAESGCMEncryptor

func NewAESGCMEncryptor(key []byte) Encryptor

func NewNoOpEncryptor

func NewNoOpEncryptor() Encryptor

type NoOpEncryptor

type NoOpEncryptor struct {
}

func (*NoOpEncryptor) Decrypt

func (e *NoOpEncryptor) Decrypt(ctx context.Context, data []byte, associatedData []byte) ([]byte, error)

func (*NoOpEncryptor) Encrypt

func (e *NoOpEncryptor) Encrypt(ctx context.Context, data []byte, associatedData []byte) ([]byte, error)

Jump to

Keyboard shortcuts

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