store

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AES

type AES struct{}

func (AES) Decrypt

func (AES) Decrypt(cryptoText string, key string) (string, error)

func (AES) Encrypt

func (AES) Encrypt(text string, key string) (string, error)

type Crypto

type Crypto interface {
	Encrypt(data string, password string) (string, error)
	Decrypt(data string, password string) (string, error)
}

type Info

type Info interface {
	// Human-readable type for key listing
	GetType() KeyType
	// Name of the key
	GetName() string
	// Public key
	GetPubKey() crypto.PubKey
}

Info is the publicly exposed information about a keypair

type KeyDAO

type KeyDAO interface {
	// Write will use user password to encrypt data and save to file, the file name is user name
	Write(name, password string, store KeyInfo) error

	// Read will read encrypted data from file and decrypt with user password
	Read(name, password string) (KeyInfo, error)

	// Delete will delete user data and use user password to verify permissions
	Delete(name, password string) error

	// Has returns whether the specified user name exists
	Has(name string) bool
}

func NewLevelDB

func NewLevelDB(rootDir string, crypto Crypto) (KeyDAO, error)

type KeyInfo

type KeyInfo struct {
	Name         string `json:"name"`
	PubKey       []byte `json:"pubkey"`
	PrivKeyArmor string `json:"priv_key_armor"`
	Algo         string `json:"algo"`
}

KeyInfo saves the basic information of the key

type KeyType

type KeyType uint

KeyType reflects a human-readable type for key listing.

type LevelDBDAO

type LevelDBDAO struct {
	Crypto
	// contains filtered or unexported fields
}

func (LevelDBDAO) Delete

func (k LevelDBDAO) Delete(name, password string) error

Delete a key message

func (LevelDBDAO) Has

func (k LevelDBDAO) Has(name string) bool

Query whether key information exists locally

func (LevelDBDAO) Read

func (k LevelDBDAO) Read(name, password string) (store KeyInfo, err error)

Read key information locally

func (LevelDBDAO) Write

func (k LevelDBDAO) Write(name, password string, store KeyInfo) error

Write a key message and store it locally

type MemoryDAO

type MemoryDAO struct {
	Crypto
	// contains filtered or unexported fields
}

Use memory as storage, use with caution in build environment

func NewMemory

func NewMemory(crypto Crypto) MemoryDAO

func (MemoryDAO) Delete

func (m MemoryDAO) Delete(name, password string) error

func (MemoryDAO) Has

func (m MemoryDAO) Has(name string) bool

func (MemoryDAO) Read

func (m MemoryDAO) Read(name, password string) (KeyInfo, error)

func (MemoryDAO) Write

func (m MemoryDAO) Write(name, password string, store KeyInfo) error

Jump to

Keyboard shortcuts

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