libsodium

package
v0.0.0-...-86c6960 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const KeyTransformBase64 = "base64"
View Source
const KeyTransformHex = "hex"
View Source
const KeyTransformNone = "none"

Variables

This section is empty.

Functions

func CrypterFromKey

func CrypterFromKey(key string, keyTransform string) crypto.Crypter

CrypterFromKey creates Crypter from key

func CrypterFromKeyPath

func CrypterFromKeyPath(path string, keyTransform string) crypto.Crypter

CrypterFromKeyPath creates Crypter from key path

func NewReader

func NewReader(reader io.Reader, key []byte) io.Reader

NewReader creates Reader from ordinary reader and key

func NewWriter

func NewWriter(writer io.Writer, key []byte) io.WriteCloser

NewWriter creates Writer from ordinary writer and key

Types

type Crypter

type Crypter struct {
	KeyInline    string
	KeyPath      string
	KeyTransform string
	// contains filtered or unexported fields
}

Crypter is libsodium Crypter implementation

func (*Crypter) Decrypt

func (crypter *Crypter) Decrypt(reader io.Reader) (io.Reader, error)

Decrypt creates decrypted reader from ordinary reader

func (*Crypter) Encrypt

func (crypter *Crypter) Encrypt(writer io.Writer) (io.WriteCloser, error)

Encrypt creates encryption writer from ordinary writer

func (*Crypter) Name

func (crypter *Crypter) Name() string

type ErrShortKey

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

func (ErrShortKey) Error

func (e ErrShortKey) Error() string

type Reader

type Reader struct {
	io.Reader
	// contains filtered or unexported fields
}

Reader wraps ordinary reader with libsodium decryption

func (*Reader) Read

func (reader *Reader) Read(p []byte) (n int, err error)

Read implements io.Reader

type Writer

type Writer struct {
	io.Writer
	// contains filtered or unexported fields
}

Writer wraps ordinary writer with libsodium encryption

func (*Writer) Close

func (writer *Writer) Close() (err error)

Close implements io.Closer

func (*Writer) Write

func (writer *Writer) Write(p []byte) (n int, err error)

Write implements io.Writer

Jump to

Keyboard shortcuts

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