encrypter

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 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 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.

View Source
var ErrNotSupported = errors.New("encrypted method is not supported")

ErrNotSupported describes an error in which the encrypted method is no known or supported.

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 default encrypter instance.

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