mirror of
https://github.com/wneessen/apg-go.git
synced 2024-11-24 23:00:50 +01:00
Winni Neessen
2822f73f56
Introduced a new password generation algorithm, called 'coinflip', which simply returns "Heads" or "Tails". Associated CLI flag has been added as well. Also, improved error messages during password generation. This addition provides a simpler algorithm option and clearer user feedback during errors.
34 lines
859 B
Go
34 lines
859 B
Go
package apg
|
|
|
|
// Algorithm is a type wrapper for an int type to represent different
|
|
// password generation algorithm
|
|
type Algorithm int
|
|
|
|
const (
|
|
// AlgoPronouncable represents the algorithm for pronouncable passwords
|
|
// (koremutake syllables)
|
|
AlgoPronouncable Algorithm = iota
|
|
// AlgoRandom represents the algorithm for purely random passwords according
|
|
// to the provided password modes/flags
|
|
AlgoRandom
|
|
// AlgoCoinFlip represents a very simple coinflip algorithm returning "heads"
|
|
// or "tails"
|
|
AlgoCoinFlip
|
|
// AlgoUnsupported represents an unsupported algorithm
|
|
AlgoUnsupported
|
|
)
|
|
|
|
// IntToAlgo takes an int value as input and returns the corresponding
|
|
// Algorithm
|
|
func IntToAlgo(a int) Algorithm {
|
|
switch a {
|
|
case 0:
|
|
return AlgoPronouncable
|
|
case 1:
|
|
return AlgoRandom
|
|
case 2:
|
|
return AlgoCoinFlip
|
|
default:
|
|
return AlgoUnsupported
|
|
}
|
|
}
|