crypto

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(encryptedBase64 string, key []byte) (string, error)

func DecryptFile

func DecryptFile(sourceFilePath string, targetFilePath string, key []byte) error

Read from a source text file, decrypt, and write to a target file

func DecryptFromFile

func DecryptFromFile(inputFilePath string, key []byte) (string, error)

Decrypt data read from a text file

func DecryptFromReader added in v1.1.0

func DecryptFromReader(reader io.Reader, key []byte) (string, error)

DecryptFromReader decrypts data read from an io.Reader.

func DecryptStdin

func DecryptStdin(key []byte) (string, error)

Decrypt data from the stdin pipe

func DecryptToFile

func DecryptToFile(input string, outputFilePath string, key []byte, append bool) error

Decrypt an input string to a file, with an option to append or overwrite

func Encrypt

func Encrypt(input string, key []byte) (string, error)

func EncryptFile

func EncryptFile(sourceFilePath string, targetFilePath string, key []byte) error

Read from a source text file, encrypt, and write to a target file

func EncryptFromFile

func EncryptFromFile(inputFilePath string, key []byte) (string, error)

Encrypt data read from a text file

func EncryptFromReader added in v1.1.0

func EncryptFromReader(reader io.Reader, key []byte) (string, error)

EncryptFromReader encrypts data read from an io.Reader.

func EncryptStdin

func EncryptStdin(key []byte) (string, error)

Encrypt data from the stdin pipe

func EncryptToBytes added in v1.1.0

func EncryptToBytes(input string, key []byte) ([]byte, error)

func EncryptToFile

func EncryptToFile(input string, outputFilePath string, key []byte, append bool) error

Encrypt an input string to a file, with an option to append or overwrite

Types

type KeyManager added in v1.1.0

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

KeyManager stores encryption keys externally

func NewKeyManager added in v1.1.0

func NewKeyManager() *KeyManager

NewKeyManager initializes an external key manager

func (*KeyManager) DeleteKey added in v1.1.0

func (km *KeyManager) DeleteKey(id string)

DeleteKey removes a key from the key manager

func (*KeyManager) GenerateKey added in v1.1.0

func (km *KeyManager) GenerateKey(id string) ([]byte, error)

GenerateKey creates a new AES-256 key

func (*KeyManager) GetKey added in v1.1.0

func (km *KeyManager) GetKey(id string) ([]byte, error)

GetKey retrieves a key from the key manager

type SecureKVStore added in v1.1.0

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

SecureKVStore is an in-memory encrypted key-value store

func NewSecureKVStore added in v1.1.0

func NewSecureKVStore(km *KeyManager) *SecureKVStore

NewSecureKVStore initializes a new secure in-memory store

func (*SecureKVStore) Clear added in v1.1.0

func (s *SecureKVStore) Clear()

Clear removes all values from the store

func (*SecureKVStore) Delete added in v1.1.0

func (s *SecureKVStore) Delete(key string)

Delete removes a key from the store

func (*SecureKVStore) Get added in v1.1.0

func (s *SecureKVStore) Get(key string) (string, error)

Get retrieves and decrypts a value from memory

func (*SecureKVStore) Len added in v1.1.0

func (s *SecureKVStore) Len() int

func (*SecureKVStore) ListKeys added in v1.1.0

func (s *SecureKVStore) ListKeys() []string

func (*SecureKVStore) MatchValue added in v1.1.0

func (s *SecureKVStore) MatchValue(value string) bool

func (*SecureKVStore) Put added in v1.1.0

func (s *SecureKVStore) Put(key, value string) error

Put securely stores an encrypted key-value pair in memory

Jump to

Keyboard shortcuts

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