mirror of
https://github.com/wneessen/apg-go.git
synced 2024-11-13 01:12:56 +01:00
Winni Neessen
ac97b94ec9
Refactored the generator to include a new config option, changed function signatures to follow the new structure, and renamed the function 'RandomString' to 'RandomStringFromCharRange' for clarity. Also, added a new mode and algorithm feature to enhance password generation. Furthermore, added several tests for new features and configurations. Adapted the CLI to use the new configuration approach. This refactoring was necessary to improve the customizability and clarity of the password generation process. Fixed minor issues and added '.gitignore' for clean commits in the future.
29 lines
684 B
Go
29 lines
684 B
Go
package apg
|
|
|
|
// Algorithm is a type wrapper for an int type to represent different
|
|
// password generation algorithm
|
|
type Algorithm int
|
|
|
|
const (
|
|
// Pronouncable represents the algorithm for pronouncable passwords
|
|
// (koremutake syllables)
|
|
Pronouncable Algorithm = iota
|
|
// Random represents the algorithm for purely random passwords according
|
|
// to the provided password modes/flags
|
|
Random
|
|
// Unsupported represents an unsupported algorithm
|
|
Unsupported
|
|
)
|
|
|
|
// IntToAlgo takes an int value as input and returns the corresponding
|
|
// Algorithm
|
|
func IntToAlgo(a int) Algorithm {
|
|
switch a {
|
|
case 0:
|
|
return Pronouncable
|
|
case 1:
|
|
return Random
|
|
default:
|
|
return Unsupported
|
|
}
|
|
}
|