Add secure byte slice erase helper; add alternative input methods for Windows

This commit is contained in:
2026-02-07 22:54:02 -05:00
parent 9ee213eeb4
commit e1bb0012a7
6 changed files with 151 additions and 25 deletions
+24
View File
@@ -0,0 +1,24 @@
package front
import (
"fmt"
"os"
"golang.org/x/term"
)
// InputMenuGen prompts the user with a menu and returns the user's choice as an integer.
func InputMenuGen(prompt string, options []string) int {
for i, option := range options {
fmt.Printf("%d. %s\n", i+1, option)
}
return InputInt("\n"+prompt, 1, len(options))
}
// InputHidden prompts the user for input and returns the input as a byte array, hiding the input from the terminal.
func InputHidden(prompt string) []byte {
fmt.Print(prompt + " ")
byteInput, _ := term.ReadPassword(int(os.Stdin.Fd()))
fmt.Println()
return byteInput
}