Documentation ¶
Index ¶
- func DecryptFileContents(data []byte, key []byte) (ret_pain_text []byte, ret_error error)
- func EncryptFileContents(data []byte, method FileEncryptionMethod, key []byte) (ret_cipher_text []byte, ret_error error)
- type FileBlockEncryptReadStream
- func (file *FileBlockEncryptReadStream) BlockCount() int64
- func (file *FileBlockEncryptReadStream) BlockSize() int64
- func (file *FileBlockEncryptReadStream) Close()
- func (file *FileBlockEncryptReadStream) Cursor() int64
- func (file *FileBlockEncryptReadStream) FileSize() int64
- func (file *FileBlockEncryptReadStream) Read(buf []byte) (int, error)
- func (file *FileBlockEncryptReadStream) Seek(pos int64, whence int) (int64, error)
- type FileBlockEncryptWriteStream
- type FileEncryptionMethod
- type MultiFilePackReadStream
- type MultiFilePackWriteStream
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecryptFileContents ¶
Decrypts file contents data - Cipher text key - Decryption key Returns the original file data, or an error
func EncryptFileContents ¶
func EncryptFileContents(data []byte, method FileEncryptionMethod, key []byte) (ret_cipher_text []byte, ret_error error)
Encrypts file contents data - File data method - algorithm to use key - Encryption key Returns the cipher text, or an error
Types ¶
type FileBlockEncryptReadStream ¶
type FileBlockEncryptReadStream struct {
// contains filtered or unexported fields
}
Status of a read stream
func CreateFileBlockEncryptReadStream ¶
func CreateFileBlockEncryptReadStream(file string, key []byte, perm fs.FileMode) (*FileBlockEncryptReadStream, error)
Creates a read stream file - Path to the file key - Decryption key perm - File mode
func (*FileBlockEncryptReadStream) BlockCount ¶
func (file *FileBlockEncryptReadStream) BlockCount() int64
Returns the block count
func (*FileBlockEncryptReadStream) BlockSize ¶
func (file *FileBlockEncryptReadStream) BlockSize() int64
Returns the block size
func (*FileBlockEncryptReadStream) Close ¶
func (file *FileBlockEncryptReadStream) Close()
Closes the read stream
func (*FileBlockEncryptReadStream) Cursor ¶
func (file *FileBlockEncryptReadStream) Cursor() int64
Returns the cursor position
func (*FileBlockEncryptReadStream) FileSize ¶
func (file *FileBlockEncryptReadStream) FileSize() int64
Returns the file size
func (*FileBlockEncryptReadStream) Read ¶
func (file *FileBlockEncryptReadStream) Read(buf []byte) (int, error)
Reads from stream, returns the amount of bytes obtained Normally reads until the buffer is full, unless the file ends buf - Buffer to fill Returns the number of bytes read
func (*FileBlockEncryptReadStream) Seek ¶
func (file *FileBlockEncryptReadStream) Seek(pos int64, whence int) (int64, error)
Moves the cursor pos - Position for the cursor to move whence - Position interpretation method. Can be 0 = absolute, 1 = Relative to current position, 2 = Relative to file end Returns the new cursor position (absolute)
type FileBlockEncryptWriteStream ¶
type FileBlockEncryptWriteStream struct {
// contains filtered or unexported fields
}
Status of a write stream
func CreateFileBlockEncryptWriteStream ¶
func CreateFileBlockEncryptWriteStream(file string, perm fs.FileMode) (*FileBlockEncryptWriteStream, error)
Creates a write stream file - Path of the file to create perm - File mode
func (*FileBlockEncryptWriteStream) Close ¶
func (file *FileBlockEncryptWriteStream) Close() error
Closes the file, writing any pending data in the buffer
func (*FileBlockEncryptWriteStream) Initialize ¶
func (file *FileBlockEncryptWriteStream) Initialize(file_size int64, block_size int64, key []byte) error
Initializes the file Must be called before any writes file_size - Size of the original file to encrypt block_size - Block size in bytes key - Encryption key
func (*FileBlockEncryptWriteStream) Write ¶
func (file *FileBlockEncryptWriteStream) Write(data []byte) error
Writes data data - Chunk of data to write
type FileEncryptionMethod ¶
type FileEncryptionMethod uint16
const ( AES256_ZIP FileEncryptionMethod = 1 // Compress data, then encrypt it with AES-256-CBC AES256_FLAT FileEncryptionMethod = 2 // Just encrypt the data with AES-256-CBC )
type MultiFilePackReadStream ¶
type MultiFilePackReadStream struct {
// contains filtered or unexported fields
}
Read stream to retrieve files from a packed file
func CreateMultiFilePackReadStream ¶
func CreateMultiFilePackReadStream(file string, perm fs.FileMode) (*MultiFilePackReadStream, error)
Creates read stream to get files from a packed file file - path to the file perm - File mode
func (*MultiFilePackReadStream) Close ¶
func (file *MultiFilePackReadStream) Close()
Closes the read stream
func (*MultiFilePackReadStream) FileCount ¶
func (file *MultiFilePackReadStream) FileCount() int64
Returns the number of files in the container
type MultiFilePackWriteStream ¶
type MultiFilePackWriteStream struct {
// contains filtered or unexported fields
}
Write stream data
func CreateMultiFilePackWriteStream ¶
func CreateMultiFilePackWriteStream(file string, perm fs.FileMode) (*MultiFilePackWriteStream, error)
Creates stream to write multiple files in a packed file file - Path of the file perm - file mode
func (*MultiFilePackWriteStream) Close ¶
func (file *MultiFilePackWriteStream) Close() error
Closes the stream
func (*MultiFilePackWriteStream) Initialize ¶
func (file *MultiFilePackWriteStream) Initialize(file_count int64) error
Initializes write stream (must be called before writing any files) file_count - Number of files to write
func (*MultiFilePackWriteStream) PutFile ¶
func (file *MultiFilePackWriteStream) PutFile(content []byte) error
Writes a file into the packed file content - Content of the file Calling this increases the current file index