Skip to content

aopoltorzhicky/keyring

Repository files navigation

Keyring

Library for key management

Install binary

go install github.com/aopoltorzhicky/keyring/cmd/go-keyring@latest

Get package

go get github.com/aopoltorzhicky/keyring

Usage binary

# set key
go-keyring set
# get key
go-keyring get
# remove key
go-keyring delete

Usage libary

Support only File realization which store encrypted keys in YAML file. It realize interface Keyring which contains next methods:

Set(service, user, password string) error
Get(service, user string) (string, error)
Delete(service, user string) error

Code example

keyringPassword := []byte("keyringPassword")
if err := keyring.Create(keyringPassword); err != nil {
    log.Panic().Err(err).Msg("error during creating keyring")
}

if err := keyring.Keys.Set("service", "username", "password"); err != nil {
    log.Panic().Err(err).Msg("error during setting password")
}

password, err := keyring.Keys.Get("service", "username")
if err != nil {
    log.Panic().Err(err).Msg("error during getting password")
}
log.Print(password)

if err := keyring.Keys.Delete("service", "username"); err != nil {
    log.Panic().Err(err).Msg("error during deleting password")
}

About

Library for key management

Resources

Stars

Watchers

Forks

Languages