mirror of
https://github.com/wneessen/apg-go.git
synced 2024-11-22 05:40:51 +01:00
Winni Neessen
69bb1e4cb7
Test suite `TestIntToAlgo` was added to `algo_test.go` to validate `IntToAlgo` function. Additionally, Algorithm constants in `algo.go` have been prefixed with "Algo". These changes were made in order to make the code clearer and ensure the function returns the expected values for the given inputs.
29 lines
720 B
Go
29 lines
720 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
|
|
// 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
|
|
default:
|
|
return AlgoUnsupported
|
|
}
|
|
}
|