package spg

/**
 * Secure Password Generator.
 *
 * Lovingly handcrafted by Dave Teare on October 20th, 2017
 * Cruelly butchered by Jeffrey Goldberg in February 2018
 */

// FloatE is the float type bits of a generated password.
// It is only useful (externally) if you are creating your
// own Password SeparatorFunc.
type FloatE float32

// Password is what gets generated by the Generators
type Password struct {
	tokens  Tokens  // A slice of Tokens that comprise the guts of the password
	Entropy float32 // Entropy in bits of the Recipe from which this password was generated
}

// Generator is a fully configured password recipe
type Generator interface {
	Generate() (*Password, error)
	Entropy() float32
}

// Tokens returns the tokens
func (p Password) Tokens() Tokens { return p.tokens }

// String is the Stringer. It produces the password as string one might expect
func (p Password) String() string {
	pw := ""
	for _, tok := range p.tokens {
		pw += tok.Value()
	}
	return pw
}

/**
 ** Copyright 2017, 2018 AgileBits, Inc.
 ** Licensed under the Apache License, Version 2.0 (the "License").
 **/
