cryptus

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2025 License: MIT Imports: 17 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewChacha20Poly1305Key added in v1.0.5

func NewChacha20Poly1305Key(key []byte) (cipher.AEAD, error)

Types

type Cryptus

type Cryptus interface {
	RandomSixDigits() string

	GenerateNonceBytes(n int) ([]byte, error)
	GenerateNonceHex(n int) (string, error)
	GenerateNonceB64URL(n int) (string, error)

	Sha256Hex(s string) string

	Pbkdf2(plainText, salt string, extra ...KdfConfig) string

	Argon2Hex(plain, salt []byte, extra ...KdfConfig) (string, error)
	CompareHashHex(aHex, bHex string) bool
	Argon2(plain, salt string, extra ...KdfConfig) (string, error)
	CompareArgon2(password, encoded string) bool

	EncryptAESGCMHex(plainText, keyHex, nonceHex string) (string, error)
	DecryptAESGCMHex(cipherHex, keyHex, nonceHex string) (string, error)

	EncryptChaCha20Hex(plainText, keyHex, nonceHex string) (string, error)
	DecryptChaCha20Hex(cipherHex, keyHex, nonceHex string) (string, error)

	GenerateRsaKeyPair(size int) (privPEM, pubPEM string, err error)
	EncryptRsaOAEPB64(plainText, publicKeyPEM string) (string, error)
	DecryptRsaOAEPB64(cipherB64, privateKeyPEM string) (string, error)
}

func New

func New() Cryptus

type KdfConfig

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

func NewKdfConfig

func NewKdfConfig(options ...KdfOption) KdfConfig

func (KdfConfig) Iterations

func (k KdfConfig) Iterations() int

func (KdfConfig) Length

func (k KdfConfig) Length() int

func (KdfConfig) Memory

func (k KdfConfig) Memory() int

func (KdfConfig) Threads

func (k KdfConfig) Threads() int

type KdfOption

type KdfOption func(*KdfConfig)

func WithIterations

func WithIterations(v int) KdfOption

func WithLength

func WithLength(v int) KdfOption

func WithMemory

func WithMemory(v int) KdfOption

func WithThreads

func WithThreads(v int) KdfOption

Jump to

Keyboard shortcuts

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