Documentation ¶
Index ¶
- Constants
- func DownloadLists() (map[int]string, error)
- func LoadFilters() (filters map[Rarity]BloomFilter, err error)
- func RebuildFilters() (map[Rarity]BloomFilter, error)
- type BFilter
- type BitSet
- type BitSetMap
- func (bl *BitSetMap) LoadFromFile(pathToFile string) (list map[Rarity]BloomFilter, err error)
- func (bl *BitSetMap) LoadFromRebuild(filters map[Rarity]BloomFilter) error
- func (bl *BitSetMap) MarshalJSON() ([]byte, error)
- func (bl *BitSetMap) UnmarshalJSON(data []byte) error
- func (bl *BitSetMap) WriteToFile(pathToFile string) error
- type BloomFilter
- type HomogeneityError
- type Rarity
- type TooCommonError
Constants ¶
const CacheFolder = "cache" + string(os.PathSeparator)
CacheFolder keeps a single reference to password list directory
const DefaultBitsetFilename = "defaultFilter.json"
DefaultBitsetFilename determines what file the pre-compiled filter exists or gets rebuilt
Variables ¶
This section is empty.
Functions ¶
func DownloadLists ¶
DownloadLists encapsulates code for downloading common password list(s) and provides a returned list of the sizes and paths to downloaded files
func LoadFilters ¶
func LoadFilters() (filters map[Rarity]BloomFilter, err error)
LoadFilters loads the BloomFilters from the Default BitsetFile location
func RebuildFilters ¶
func RebuildFilters() (map[Rarity]BloomFilter, error)
RebuildFilters looks at the default filter paths and rebuilds the Bloomfilters
Types ¶
type BFilter ¶
type BFilter interface { Add(item []byte) error // Adds the item into the Set Test(item []byte) (bool, error) // Check if items is maybe in the Set }
BFilter enforces what a Bloom Filter is (as function prototypes)
type BitSet ¶
type BitSet struct {
Set []bool `json:"bitset"`
}
BitSet holds a slice of ZeroOneBools for custom Marshall/Unmarshall
func (*BitSet) MarshalJSON ¶
MarshalJSON marshals the boolean types to string 0 or 1
func (*BitSet) UnmarshalJSON ¶
UnmarshalJSON unpacks the string 1 or 0 to a set of sythetic boolean type
type BitSetMap ¶
type BitSetMap struct { // map of the bitsets indexed by # of elements (pws) in the filter List map[Rarity]BitSet `json:"list"` }
BitSetMap holds lists of the built filters for json storage/loading
func (*BitSetMap) LoadFromFile ¶
func (bl *BitSetMap) LoadFromFile(pathToFile string) (list map[Rarity]BloomFilter, err error)
LoadFromFile reads in the BitSetMap stored in JSON by BitSetMap.WriteToFile()
func (*BitSetMap) LoadFromRebuild ¶
func (bl *BitSetMap) LoadFromRebuild(filters map[Rarity]BloomFilter) error
LoadFromRebuild takes in the map from LoadFromFile or DownloadLists and puts the filters into the BitSetMap
func (*BitSetMap) MarshalJSON ¶
MarshalJSON overrides the interface{} marshalling behavior or BitsetMap
func (*BitSetMap) UnmarshalJSON ¶
UnmarshalJSON defines custom interaction with BitSet.UnmarshalJSON
func (*BitSetMap) WriteToFile ¶
WriteToFile puts the BitSetMap in a persistent filestor in JSON format
type BloomFilter ¶
type BloomFilter struct { Bitset []bool // The bloom-filter bitset N uint // Number of elements in the filter // contains filtered or unexported fields }
BloomFilter probabilistic bloom filter struct
func NewBloom ¶
func NewBloom(n int) *BloomFilter
NewBloom returns a new BloomFilter struct with n bits and default hash funcs
func (*BloomFilter) Add ¶
func (b *BloomFilter) Add(item []byte) error
Add the item into the bloom filter set by hashing in over the hash functions
func (*BloomFilter) GetBitset ¶
func (b *BloomFilter) GetBitset() []bool
GetBitset for returing the inner slice of booleans is needed for testing the bloom filters
type HomogeneityError ¶
HomogeneityError creates a switchable type of error for low entropy
func (*HomogeneityError) Error ¶
func (h *HomogeneityError) Error() string
type TooCommonError ¶
TooCommonError creates a switchable type of error for common passwords
func (*TooCommonError) Error ¶
func (t *TooCommonError) Error() string