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
|
|
|
|
// 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-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
|
|
|
}
|
|
|
|
}
|