apg-go/algo.go
Winni Neessen acadccc84a
Add binary mode for secret generation
This commit updates the password generator to now include a binary mode. This mode produces a 256 bits long fully binary secret which can be used for AES-256 encryption. New flags `-bh` (print hex representation) and `-bn` (new line after secret) have been added for this mode. The version has also been updated to 1.0.1 recognizing this new addition.
2024-03-17 18:09:27 +01:00

43 lines
1.1 KiB
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
// AlgoBinary represents a full binary randomness mode with up to 256 bits
// of randomness
AlgoBinary
// 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
case 3:
return AlgoBinary
default:
return AlgoUnsupported
}
}