cipherio

package
v0.0.0-...-36df34d Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// When doing reads or writes, the size of data to work with in bytes.
	// 5MB is the minimum size for an aws multipart upload.
	IO_BLOCK_SIZE = 1024 * 1024 * 5
)

Variables

This section is empty.

Functions

func NewCipherReader

func NewCipherReader(reader util.ReadSeekCloser,
	blockCipher cipher.Block, rawIV []byte,
	ciphertextSize int64) (util.ReadSeekCloser, error)

Caller gives up control of the reader.

Types

type CipherReader

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

A ReadSeekCloser that will read an encrypted file, decrypt them, and return the cleartext all in chunks of size IO_BLOCK_SIZE. Note that the cleartext will be in chunks of IO_BLOCK_SIZE, but the cipertext read will be slightly larger.

func (*CipherReader) Close

func (this *CipherReader) Close() error

func (*CipherReader) Read

func (this *CipherReader) Read(outBuffer []byte) (int, error)

func (*CipherReader) Seek

func (this *CipherReader) Seek(offset int64, whence int) (int64, error)

type CipherWriter

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

A WriteCloser that will write an encrypted file from cleartext bytes. All writes to the actual storage made by this writer will be in chunks of IO_BLOCK_SIZE (+ the overhead for cipertext). It is possible to write everything at once, but this writer is really meant to be streamed in smaller (closer to IO_BLOCK_SIZE) chunks. Close() MUST BE CALLED after all reading is finished. Without the Close() call, the final chunk will not get writen. The file size (cleartext) and md5 will be available after the writer is closed.

func NewCipherWriter

func NewCipherWriter(writer io.WriteCloser,
	blockCipher cipher.Block, rawIV []byte) (*CipherWriter, error)

func (*CipherWriter) Close

func (this *CipherWriter) Close() error

func (*CipherWriter) GetFileSize

func (this *CipherWriter) GetFileSize() uint64

func (*CipherWriter) GetHash

func (this *CipherWriter) GetHash() string

Get the md5 as a hex string.

func (*CipherWriter) Write

func (this *CipherWriter) Write(data []byte) (int, error)

Jump to

Keyboard shortcuts

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