payload

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyPayload       = errors.New("crypha: empty payload")
	ErrBadMagic           = errors.New("crypha: not a crypha payload (bad magic)")
	ErrUnsupportedVersion = errors.New("crypha: unsupported envelope version")
	ErrTruncated          = errors.New("crypha: truncated envelope")
	ErrBadParams          = errors.New("crypha: invalid key-derivation parameters")
	ErrChecksumMismatch   = errors.New("crypha: checksum mismatch")
	ErrPassphraseRequired = errors.New("crypha: payload is encrypted, passphrase required")
	ErrDecrypt            = errors.New("crypha: decryption failed (wrong passphrase or tampered data)")
	ErrUnknownCipher      = errors.New("crypha: unknown cipher")
)

Functions

func EnvelopeSize

func EnvelopeSize(data []byte, opts Options) (int, error)

func IsEncrypted

func IsEncrypted(env []byte) (bool, error)

func Overhead

func Overhead(encrypted bool) int

func Pack

func Pack(data []byte, opts Options) ([]byte, error)

func Unpack

func Unpack(env, passphrase []byte) ([]byte, error)

func Validate

func Validate(env []byte) error

Types

type Cipher

type Cipher string
const (
	CipherChaCha20  Cipher = "chacha20"
	CipherAES256GCM Cipher = "aes256gcm"
)

type Options

type Options struct {
	Passphrase []byte
	Compress   bool
	Cipher     Cipher
	Strength   Strength
}

type Strength

type Strength string
const (
	StrengthDefault Strength = "default"
	StrengthHigh    Strength = "high"
)

Jump to

Keyboard shortcuts

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