Golang : Get password from console input without echo or masked
Found this package https://github.com/howeyc/gopass that allows Golang developers to build text based application that takes in password without echo(silent mode) or use masking.
For example :
package main
import (
"fmt"
"github.com/howeyc/gopass"
)
func main() {
fmt.Printf("Enter silent password: ")
silentPassword := gopass.GetPasswd() // Silent
// input is in byte and need to convert to string
// for storing and comparison
fmt.Println(string(silentPassword))
fmt.Printf("Enter masked password: ")
maskedPassword := gopass.GetPasswdMasked() // Masked
fmt.Println(string(maskedPassword))
}
Sample output :
Enter silent password:
abc
Enter masked password: ********
abc12345
See also : Golang : Bcrypting password
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+27.2k Golang : dial tcp: too many colons in address
+9.5k PHP : Get coordinates latitude/longitude from string
+12.5k Golang : Listen and Serve on sub domain example
+9.9k Golang : Test a slice of integers for odd and even numbers
+6.6k Golang : Muxing with Martini example
+34.3k Golang : How to stream file to client(browser) or write to http.ResponseWriter?
+9.2k Mac OSX : Get a process/daemon status information
+7k Golang : Dealing with postal or zip code example
+7.8k Golang : Grayscale Image
+36.1k Golang : Validate IP address
+8.7k Golang : Find network service name from given port and protocol