Documentation ¶
Index ¶
- Variables
- type Alphabet
- type PasswordTranscoder
- type Storage
- func (s *Storage) AddSection(section string) error
- func (s *Storage) CheckPassphrase(pass string) error
- func (s *Storage) DumpOnDisk() error
- func (s *Storage) Get(section string, password string) (string, error)
- func (s *Storage) ListAll() map[string][]string
- func (s *Storage) ListPasswords(section string) []string
- func (s *Storage) ListSections() []string
- func (s *Storage) Set(section string, password string, data string)
- func (s *Storage) SetNewPassphrase(old string, new string) error
Constants ¶
This section is empty.
Variables ¶
var Alphas []Alphabet = []Alphabet{ Alphabet{ "[0-9]", "0123456789", }, Alphabet{ "[a-zA-Z]", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", }, Alphabet{ "[a-zA-Z0-9]", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", }, Alphabet{ "[a-zA-Z0-9!&()*+,-./?[]~]", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!&()*+,-./?[]~", }, Alphabet{ "[a-zA-Z0-9 !\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~]", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 !\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~]", }, }
Alphas contains all the pre-defined alphabets.
Functions ¶
This section is empty.
Types ¶
type Alphabet ¶
type Alphabet struct { // String to display on the prompt Display string // contains filtered or unexported fields }
An Alphabet abstract the character set from which the password will be randomly created.
func (Alphabet) GenPassword ¶
GenPassword creates a random password of given length, using Golang's cryptographically secure PRNG (which is just a wrapper around your OS's cryptographically secure PRNG, so if you find a problem of randomness in it, that's something you can be proud of).
type PasswordTranscoder ¶
type PasswordTranscoder interface { // DecodePassword takes an encoded password as an input, and decode if then decypts it. DecodePassword(pass string) ([]byte, error) // EncodePassword takes a password as an input, and encrypts then encode it to printable characters. If an error occurs, it should raise it. EncodePassword(pass string) ([]byte, error) }
Interface to be implemented for an encryption and encoding scheme
func NewTranscoder ¶
func NewTranscoder(s string) PasswordTranscoder
type Storage ¶
type Storage struct { // Passphrase of the user. That's a bcrypt hash. Passphrase string `json:"Pass"` // The different sections of the file. The format is the following: // - section_name_1: // * pass_name_1: encrypted_pass_1 // * pass_name_2: encrypted_pass_2 // - section_name_2: // * pass_name_1: encrypted_pass_1 // * pass_name_2: encrypted_pass_2 Sections map[string]map[string]string `json:"Sections"` }
Storage is used to keep track of both the user master file
func GetStorage ¶
GetStorage reads the master file, and creates the matching storage object if possible. If not, an error is raised (invalid permissions, non-existent file, wrong formatting, etc ...
func InitPassphrase ¶
InitPassphrase creates a new storage with given passphrase
func (*Storage) AddSection ¶
AddSection adds a section to the storage.
func (*Storage) CheckPassphrase ¶
CheckPassphrase verifies the given passphrase against the stored hash using bcrypt's hash function.
func (*Storage) DumpOnDisk ¶
Saves the file on the disk, raises an error if necessary with JSON formatting
func (*Storage) Get ¶
Get retrieves an encrypted password from the storage. If the section or the password do not exist, an error is raised.
func (*Storage) ListPasswords ¶
ListPasswords lists all the password contained in the section.
func (*Storage) ListSections ¶
ListSections retrieves all the sections from the storage.
func (*Storage) Set ¶
Set puts a new encrypted password on the storage. Be extra-careful, it does not actually encrypts and encode it.
func (*Storage) SetNewPassphrase ¶
SetNewPassphrase changes from the old passphrase to the new one. It checks for validity of the old one first, then decrypts all passwords and re-encrypts them with the new passphrase. If there is an error during this operation, nothing is comitted.