mirror of
https://github.com/wneessen/apg-go.git
synced 2024-11-22 05:40:51 +01:00
Winni Neessen
79f921f9ad
This commit introduces the .gitignore configuration file and adds SPDX headers to several files including test and documentation files. The headers provide license information in a standardized format which can be easily picked up by automated tools for license compliance checks. Additionally, it deleted a .idea/.gitignore file, which is a project specific IDE configuration file not necessary for the repository. It also introduced a README.md file providing more insightful information about the project.
38 lines
967 B
Go
38 lines
967 B
Go
// SPDX-FileCopyrightText: 2021-2024 Winni Neessen <wn@neessen.dev>
|
|
//
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package apg
|
|
|
|
// Algorithm is a type wrapper for an int type to represent different
|
|
// password generation algorithm
|
|
type Algorithm int
|
|
|
|
const (
|
|
// AlgoPronounceable represents the algorithm for pronounceable passwords
|
|
// (koremutake syllables)
|
|
AlgoPronounceable 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 AlgoPronounceable
|
|
case 1:
|
|
return AlgoRandom
|
|
case 2:
|
|
return AlgoCoinFlip
|
|
default:
|
|
return AlgoUnsupported
|
|
}
|
|
}
|