encrypter

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidCipher = errors.New("invalid cipher message")

ErrInvalidCipher describes an error in which the cipher message is invalid.

View Source
var ErrInvalidParam = errors.New("invalid param")

ErrInvalidParam describes an error in which the encryption parameter is invalid.

View Source
var ErrInvalidPassword = errors.New("invalid password")

ErrInvalidPassword describes an error in which the password is invalid.

View Source
var ErrMethodNotSupported = errors.New("cipher method is not supported")

ErrMethodNotSupported describes an error in which the cipher method is not known.

Functions

func OptionIteration

func OptionIteration(iterations uint32) func(p *argon2dParameters)

func OptionMemory

func OptionMemory(memory uint32) func(p *argon2dParameters)

func OptionParallelism

func OptionParallelism(parallelism uint8) func(p *argon2dParameters)

Types

type Encrypter

type Encrypter struct {
	Method string `json:"method,omitempty"`
	Params params `json:"params,omitempty"`
}

Encrypter keeps the method and parameters for the cipher algorithm.

func DefaultEncrypter

func DefaultEncrypter(opts ...Option) Encrypter

DefaultEncrypter creates a new encrypter instance. If no option sets it uses the default parameters.

The default encrypter uses Argon2ID as password hasher and AES_256_CTR as encryption algorithm.

func NopeEncrypter

func NopeEncrypter() Encrypter

NopeEncrypter creates a nope encrypter instance.

The nope encrypter doesn't encrypt the message and the cipher message is same as original message.

func (*Encrypter) Decrypt

func (e *Encrypter) Decrypt(cipherText, password string) (string, error)

Decrypt decrypts the `cipher` using give `password` and returns the original message.

func (*Encrypter) Encrypt

func (e *Encrypter) Encrypt(message, password string) (string, error)

Encrypt encrypts the `message` using give `password` and returns the cipher message.

func (*Encrypter) IsEncrypted

func (e *Encrypter) IsEncrypted() bool

type Option

type Option func(p *argon2dParameters)

Jump to

Keyboard shortcuts

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