crypto

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateCode

func GenerateCode(n int) string

func GenerateSecureToken

func GenerateSecureToken(length int) (string, error)

GenerateSecureToken generates a URL-safe base64 encoded random string

Types

type AesGcmEncryption

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

func (AesGcmEncryption) Decrypt

func (m AesGcmEncryption) Decrypt(ciphertext string) (string, error)

func (AesGcmEncryption) Encrypt

func (m AesGcmEncryption) Encrypt(plaintext string) ([]byte, error)

type Encryptor

type Encryptor interface {
	Encrypt(plaintext string) ([]byte, error)
	Decrypt(ciphertext string) (string, error)
}

func NewAesGcmEncryption

func NewAesGcmEncryption(ctx context.Context, secret string) (Encryptor, error)

type Hash

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

func (Hash) HashSHA256

func (h Hash) HashSHA256(data string) string

func (Hash) HashSHA512

func (h Hash) HashSHA512(data string) string

type Hasher

type Hasher interface {
	HashSHA256(data string) string
	HashSHA512(data string) string
}

func NewHasher

func NewHasher(ctx context.Context, secret string) (Hasher, error)

Jump to

Keyboard shortcuts

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