katana

package module
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: Apache-2.0 Imports: 10 Imported by: 4

README

Code Climate Maintainability Codacy badge
Coverage Status GitHub Actions CI Status GitHub Actions CodeQL Status

CI StatusContributingLicense


katana is Go package for transparent data encryption/decryption using DARE method using sio.

CI Status

Branch Status
master CI
develop CI

Contributing

Before contributing to this project please read our Contributing Guidelines.

License

Apache License, Version 2.0

Documentation

Index

Constants

View Source
const SALT_SIZE = 32

SALT_SIZE is default salt size

Variables

View Source
var (
	ErrNilFile         = fmt.Errorf("File is nil")
	ErrNilSecret       = fmt.Errorf("Secret is nil")
	ErrEmptySecret     = fmt.Errorf("Secret is empty")
	ErrEmptySecretData = fmt.Errorf("Secret data is empty")
	ErrEmptySecretPath = fmt.Errorf("Secret path is empty")
	ErrEmptyEnvVarName = fmt.Errorf("Environment variable name is empty")
	ErrEmptyEnvVar     = fmt.Errorf("Environment variable is empty")
)

Functions

This section is empty.

Types

type Checksum added in v0.0.4

type Checksum []byte

Checksum is secret checksum

func (Checksum) Short added in v0.0.4

func (c Checksum) Short() string

Short returns short checksum (first 7 bytes)

func (Checksum) String added in v0.0.4

func (c Checksum) String() string

String returns full checksum as string

type File

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

File represents encrypted file

func (*File) Chmod

func (f *File) Chmod(mode os.FileMode) error

Chmod changes the mode of the file to mode

func (*File) Chown

func (f *File) Chown(uid, gid int) error

Chown changes the numeric uid and gid of the named file

func (*File) Close

func (f *File) Close() error

Close closes the File, rendering it unusable for I/O

func (*File) Name

func (f *File) Name() string

Name returns the name of the file as presented to Open

func (*File) Read

func (f *File) Read(b []byte) (int, error)

Read reads up to len(b) bytes from the File and stores them in b

func (*File) Stat

func (f *File) Stat() (os.FileInfo, error)

Stat returns the FileInfo structure describing file

func (*File) String

func (f *File) String() string

String returns string representation of File

func (*File) Write

func (f *File) Write(b []byte) (int, error)

Write writes len(b) bytes from b to the File

type Mode added in v0.2.0

type Mode uint8

Mode is reader/writer mode

const (
	MODE_ENCRYPT Mode = 0 // Encryption mode
	MODE_DECRYPT Mode = 1 // Decryption mode
)

func (Mode) String added in v0.2.0

func (m Mode) String() string

String returns string representation of mode

type Reader added in v0.1.0

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

Reader is encrypted data reader

func (*Reader) Read added in v0.1.0

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

Read reads and decrypts data

func (*Reader) String added in v0.1.0

func (r *Reader) String() string

String returns string representation of reader

type Secret added in v0.0.2

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

Secret is katana secret storage

func NewSecret added in v0.0.2

func NewSecret(data string) *Secret

NewSecret creates new katana secret

func (*Secret) Add added in v0.0.2

func (s *Secret) Add(data string) *Secret

Add adds static part of the key

func (*Secret) AddBase64 added in v0.0.2

func (s *Secret) AddBase64(data string) *Secret

AddBase64 adds Base64-encoded static part of the key

func (*Secret) AddEnv added in v0.0.2

func (s *Secret) AddEnv(name string) *Secret

AddEnv adds dynamic part of the key for environment variable

func (*Secret) AddFile added in v0.0.2

func (s *Secret) AddFile(file string) *Secret

AddFile adds dynamic part of the key based on SHA-512 hash of the file

func (*Secret) AddHex added in v0.0.2

func (s *Secret) AddHex(data string) *Secret

AddHex adds hex-encoded static part of the key

func (*Secret) Checksum added in v0.0.4

func (s *Secret) Checksum() Checksum

Checksum returns secret checksum

func (*Secret) Decrypt added in v0.2.0

func (s *Secret) Decrypt(data []byte) ([]byte, error)

Decrypt decrypts given data

func (*Secret) DecryptFromBase64 added in v0.4.0

func (s *Secret) DecryptFromBase64(data []byte) ([]byte, error)

DecryptFromBase64 decrypts Base64-encoded data

func (*Secret) Encrypt added in v0.2.0

func (s *Secret) Encrypt(data []byte) ([]byte, error)

Encrypt encrypts given data

func (*Secret) EncryptToBase64 added in v0.4.0

func (s *Secret) EncryptToBase64(data []byte) ([]byte, error)

EncryptToBase64 encrypts given data and encodes result to Base64

func (*Secret) NewReader added in v0.1.0

func (s *Secret) NewReader(r io.Reader, mode Mode) (*Reader, error)

NewReader creates new reader instance

func (*Secret) NewWriter added in v0.1.0

func (s *Secret) NewWriter(w io.WriteCloser) (*Writer, error)

NewWriter creates new writer instance

func (*Secret) Open added in v0.0.2

func (s *Secret) Open(name string) (*File, error)

Open opens the named file for reading. If successful, methods on the returned file can be used for reading; the associated file descriptor has mode O_RDONLY.

func (*Secret) OpenFile added in v0.0.2

func (s *Secret) OpenFile(name string, flag int, perm os.FileMode) (*File, error)

OpenFile opens the named file with specified flag (O_RDONLY etc.). If the file does not exist, and the O_CREATE flag is passed, it is created with mode perm (before umask).

func (*Secret) ReadFile added in v0.0.3

func (s *Secret) ReadFile(name string) ([]byte, error)

ReadFile reads the named file and returns the contents

func (*Secret) String added in v0.1.0

func (s *Secret) String() string

String returns string representation of secret

func (*Secret) Validate added in v0.0.2

func (s *Secret) Validate() error

Validate validates secret

func (*Secret) WriteFile added in v0.0.3

func (s *Secret) WriteFile(name string, data []byte, perm os.FileMode) error

WriteFile writes data to the named file, creating it if necessary

type Writer added in v0.1.0

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

Reader is encrypted data writer

func (*Writer) Close added in v0.1.0

func (w *Writer) Close() error

Close closes writer

func (*Writer) String added in v0.1.0

func (w *Writer) String() string

String returns string representation of writer

func (*Writer) Write added in v0.1.0

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

Write encrypts and writes data

Directories

Path Synopsis
gob

Jump to

Keyboard shortcuts

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