encryption

package
v0.1.32 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Encryption

type Encryption struct {
	DB             initdb.DBInterface
	FI             fileutils.FileInterface
	DBConfig       initdb.DBConfigInterface
	Log            logger.LoggerInterface
	Parameters     *Parameters
	FileOps        fileutils.FileOperator
	GetWrittenData []byte
	DBInitializer  initdb.DBInitializer
	FUInitializer  fileutils.FUInitializer
}

func NewEncryption

func NewEncryption(dbcfg initdb.DBConfigInterface, dbInitializer initdb.DBInitializer, fuInitializer fileutils.FUInitializer, log logger.LoggerInterface, parameters *Parameters) *Encryption

func (*Encryption) CreateEncryptionKey

func (e *Encryption) CreateEncryptionKey(encryptedFilename string, strings []string, encFunc bool) ([]byte, error)

func (*Encryption) DecryptFile

func (e *Encryption) DecryptFile(encryptedFilename string, key []byte, toDisk bool) ([]byte, error)

Decryption Logic

func (*Encryption) EncryptFile

func (e *Encryption) EncryptFile(filename string, contentData []byte, key []byte) error
Encryption Logic

encryptFile encrypts the file with the given key and writes the encrypted data to a new file

func (*Encryption) SetLogger

func (e *Encryption) SetLogger(log logger.LoggerInterface)

type Parameters

type Parameters struct {
	PartsDir        string
	PrefixParts     string
	Timestamp       int64
	CURRENT_VERSION string
}

func NewParamters

func NewParamters(partsDir string, prefixParts string, timestamp int64, currentVersion string) *Parameters

type RealFileOps

type RealFileOps struct {
	Enc *Encryption
}

func (*RealFileOps) Create

func (r *RealFileOps) Create(name string) (*os.File, error)

func (*RealFileOps) Open

func (r *RealFileOps) Open(name string) (*os.File, error)

func (*RealFileOps) ReadFile

func (r *RealFileOps) ReadFile(name string) ([]byte, error)

func (*RealFileOps) Remove

func (r *RealFileOps) Remove(name string) error

func (*RealFileOps) WriteDecryptedFile

func (r *RealFileOps) WriteDecryptedFile(filename string, key []byte, data []byte, perm os.FileMode) error

func (*RealFileOps) WriteEncryptedFile

func (r *RealFileOps) WriteEncryptedFile(filename string, data []byte, key []byte, perm os.FileMode) error

func (*RealFileOps) WriteFile

func (r *RealFileOps) WriteFile(filename string, data []byte, perm os.FileMode) error

Jump to

Keyboard shortcuts

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