Documentation
¶
Overview ¶
The Storage package is what handles all the DB operations, beginning by creating and migrating it to Insertions and Deletes.
Secrets.go is where the operations with the DB resides.
Index ¶
- func Decrypt(encoded string, key []byte) (string, error)
- func Encrypt(plain_text string, key []byte) (string, error)
- func HashMasterKey(mk string) []byte
- type DB
- func (db *DB) AddMasterKey(key string) (int64, error)
- func (db *DB) Close() error
- func (db *DB) Delete(id int) error
- func (db *DB) GetByName(name string) (*Secret, error)
- func (db *DB) GetHashedMasterKey() (*Secret, error)
- func (db *DB) Insert(name, key string, mk []byte) (int64, error)
- func (db *DB) List() ([]Secret, error)
- func (db *DB) MasterKeyExists() (bool, error)
- func (db *DB) Update(id_to_change int, new_secret Secret, mk []byte) error
- type Secret
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Decrypt ¶
Decrypt function receives a encrypted string and a master key, it will try to decrypt it, but if master key is not the same that was used on encryption, the decription will fail.
func Encrypt ¶
Encrypt function accept plain_text and the master key hash, the later will be used as salt on the encryption, therefore the only key that can decrypt it is the one that encrypted on the first place.
func HashMasterKey ¶
HashMasterKey will hash the master key with sha256, it also add a salt to it.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB struct, only field is the connection with the actual DB.
func New ¶
New function opens your DB connection and migrate if needed, it returns a initialized DB struct and a db method for migrating.
func (*DB) AddMasterKey ¶
AddMasterKey hash the argument passed and insert it into the 'config' table, returns it's id if no error.
func (*DB) GetByName ¶
GetByName method accepts a string and then query it against the DB, if the name is found the method returns a instantiated Secret of it.
func (*DB) GetHashedMasterKey ¶
GetHashedMasterKey method get's the master key.
func (*DB) Insert ¶
Insert method accepts a name, a key, and a hashed Master Key, returns a int64 that is the id of the new row and can return a error aswell, the method is to register a new secret within the DB.
func (*DB) List ¶
List method returns a slice of instantiate Secrets, it goes trough every secret on DB saving then.
func (*DB) MasterKeyExists ¶
MasterKeyExists verify if Master Key exists.