database

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2023 License: OSL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decrypt

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

Decrypt is used to decrypt obtained encrypted vaules from the database.

func Encrypt

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

Encrypt encrypts strings using the hashed secret to be stored in the database.

Types

type DB

type DB = bun.DB

func InitDB

func InitDB() (*DB, error)

InitDB returns the databse or creates it if it does not exist.

type Entry

type Entry struct {
	bun.BaseModel `bun:"table:asunder"`

	ID       int    `bun:",pk,autoincrement"`
	Username string `survey:"username"`
	Issuer   string `survey:"issuer"`
	Secret   string `survey:"secret"`
}

Entry is a struct the holds all necessary informations for a TOTP entry.

func GetEntries

func GetEntries(db *DB, key []byte) ([]Entry, error)

type KeyHash

type KeyHash struct {
	Text string
	Hash []byte
}

KeyHash stores the hash in string and []byte format for accessibility.

func Hash

func Hash(secret string) KeyHash

Hash returns a sha256 hashed secret

Jump to

Keyboard shortcuts

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