2023-08-04 16:02:58 +02:00
|
|
|
package apg
|
|
|
|
|
|
|
|
// Algorithm is a type wrapper for an int type to represent different
|
|
|
|
// password generation algorithm
|
|
|
|
type Algorithm int
|
|
|
|
|
|
|
|
const (
|
2023-08-04 20:35:31 +02:00
|
|
|
// AlgoPronouncable represents the algorithm for pronouncable passwords
|
2023-08-04 16:02:58 +02:00
|
|
|
// (koremutake syllables)
|
2023-08-04 20:35:31 +02:00
|
|
|
AlgoPronouncable Algorithm = iota
|
|
|
|
// AlgoRandom represents the algorithm for purely random passwords according
|
2023-08-04 16:02:58 +02:00
|
|
|
// to the provided password modes/flags
|
2023-08-04 20:35:31 +02:00
|
|
|
AlgoRandom
|
2023-08-05 18:10:11 +02:00
|
|
|
// AlgoCoinFlip represents a very simple coinflip algorithm returning "heads"
|
|
|
|
// or "tails"
|
|
|
|
AlgoCoinFlip
|
2023-08-04 20:35:31 +02:00
|
|
|
// AlgoUnsupported represents an unsupported algorithm
|
|
|
|
AlgoUnsupported
|
2023-08-04 16:02:58 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
// IntToAlgo takes an int value as input and returns the corresponding
|
|
|
|
// Algorithm
|
|
|
|
func IntToAlgo(a int) Algorithm {
|
|
|
|
switch a {
|
|
|
|
case 0:
|
2023-08-04 20:35:31 +02:00
|
|
|
return AlgoPronouncable
|
2023-08-04 16:02:58 +02:00
|
|
|
case 1:
|
2023-08-04 20:35:31 +02:00
|
|
|
return AlgoRandom
|
2023-08-05 18:10:11 +02:00
|
|
|
case 2:
|
|
|
|
return AlgoCoinFlip
|
2023-08-04 16:02:58 +02:00
|
|
|
default:
|
2023-08-04 20:35:31 +02:00
|
|
|
return AlgoUnsupported
|
2023-08-04 16:02:58 +02:00
|
|
|
}
|
|
|
|
}
|