aes

package
v0.0.1-demo Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2022 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidKeyLength = errors.New("Key must be 16, 24, or 32 bytes long")
)

Functions

func FromOffset

func FromOffset(chunkSize, overhead int, offset uint64) int

FromOffset returns the index of the chunk given an offset.

func GetOffset

func GetOffset(chunkSize, overhead, index int) uint64

GetOffset returns the offset of the chunk specified by the index.

func NewReader

func NewReader(ds io.ReadSeeker, key []byte, chunkSize int, fileSize uint64) (io.ReadSeeker, error)

NewReader creates a new AESReader

func NewWriter

func NewWriter(ds io.Writer, key []byte, chunkSize int) (io.WriteCloser, error)

NewWriter creates a new AESWriter

Types

type AESReader

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

AESReader reads data from an io.Reader that was generated using AESWriter.

func (*AESReader) Read

func (r *AESReader) Read(p []byte) (int, error)

func (*AESReader) Seek

func (r *AESReader) Seek(offset int64, whence int) (int64, error)

type AESWriter

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

AESWriter generates a ciphertext to an io.Writer that can be read back using AESReader

func (*AESWriter) Close

func (w *AESWriter) Close() error

Close finalizes the writes and flushes any remaining buffered data onto the writer.

func (*AESWriter) GetRead

func (w *AESWriter) GetRead() uint64

GetRead returns the number of plaintext bytes read.

func (*AESWriter) GetWritten

func (w *AESWriter) GetWritten() uint64

GetWritten returns the number of ciphertext bytes written to the underlying writer.

func (*AESWriter) Write

func (w *AESWriter) Write(p []byte) (int, error)

Write buffers p and encrypts the buffer in chunks of chunkSize.

Jump to

Keyboard shortcuts

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