crypto

package
v0.0.0-...-5a7cb14 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2019 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ChunkSize = int64(1024 * 256) // 256KiB

Functions

func EqualHash

func EqualHash(a, b Hash) bool

func NewDecryptReadSeeker

func NewDecryptReadSeeker(key string, size int64, backingRs io.ReadSeeker) (io.ReadSeeker, error)

func NewEncname

func NewEncname() string

NewEncname generates a random 200 bit number and returns the base32 string

Types

type DecryptReadSeeker

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

func (*DecryptReadSeeker) Read

func (seeker *DecryptReadSeeker) Read(b []byte) (int, error)

func (*DecryptReadSeeker) Seek

func (seeker *DecryptReadSeeker) Seek(offset int64, whence int) (int64, error)

Only 0 whence is supported

type Encryptor

type Encryptor struct {
	ChunkIdx int64 // chuckCount used to derive nonce
	Overhead int64 // 16
	// contains filtered or unexported fields
}

func NewDecryptor

func NewDecryptor(key, iv string) *Encryptor

func NewEncryptor

func NewEncryptor() *Encryptor

NewEncryptor generates a new random key, iv

func (*Encryptor) DecryptChunk

func (e *Encryptor) DecryptChunk(plainBytes, cipherBytes []byte) ([]byte, error)

func (*Encryptor) Encrypt

func (e *Encryptor) Encrypt(out io.Writer, in io.Reader, encrypt bool) (Hash, error)

Read plain/cipher text from in io.Reader and writes plain/cipher text to out io.Writer. If encrypt is true, then in is the plaintext.

func (*Encryptor) GetIv

func (e *Encryptor) GetIv() string

func (*Encryptor) GetKey

func (e *Encryptor) GetKey() string

func (*Encryptor) Init

func (e *Encryptor) Init()

Init sets up the internal oncryptor using current key and iv.

func (*Encryptor) SetIv

func (e *Encryptor) SetIv(iv string)

func (*Encryptor) SetKey

func (e *Encryptor) SetKey(key string)

type Hash

type Hash struct {
	InSHA1    string
	InSHA256  string
	OutSHA1   string
	OutSHA256 string
}

Jump to

Keyboard shortcuts

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