Documentation ¶
Index ¶
Constants ¶
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
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.