-x, -f, env vars, prepping for hashing

This commit is contained in:
2022-05-22 04:43:12 -04:00
parent f76edd3022
commit 1d4d7c5538
15 changed files with 262 additions and 38 deletions

View File

@@ -1,5 +1,13 @@
package pwgenerator
import (
"encoding/xml"
"time"
)
// pwHash is an explicit hash algorithm.
type pwHash uint8
// cryptoShuffler is used to shuffle a slice in a cryptographically sane way.
type cryptoShuffler struct{}
@@ -56,6 +64,28 @@ type GenOpts struct {
explicitCharset CharSet
}
// PwCollection contains the full series of generated passwords.
type PwCollection struct {
XMLName xml.Name `json:"-" yaml:"-"`
Passwords []*PwDef `json:"password_defs" yaml:"Password Definitions" xml:"passwordDefs"`
}
// PwDef contains a generated password and related metadata.
type PwDef struct {
XMLName xml.Name `json:"-" yaml:"-"`
Password string `json:"password" yaml:"Password" xml:"password,attr"`
Generated time.Time `json:"generated" yaml:"Generated" xml:"generated,attr"`
Hashes []PwHashDef `json:"hashes,omitempty" yaml:"Hashes,omitempty" xml:"hashes,omitempty"`
// Hashes []PwHashDef `json:"hashes" yaml:"Hashes" xml:"hashes"`
}
// PwHashDef defines a hash for a PwDef (once we implement it).
type PwHashDef struct {
XMLName xml.Name `json:"-" yaml:"-"`
HashType string `json:"hash_algo" yaml:"Hash Algorithm" xml:"hashAlgo,attr"`
HashString string `json:"hash" yaml:"Hash" xml:",chardata"`
}
// selectFilter is used to include specified number of characters.
type selectFilter struct {
upperCounter uint