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
+3.5k Golang : Valued expressions and functions example
+5.9k Golang : Fibonacci number generator examples
+24.6k Golang : missing Mercurial command
+17.2k Golang : Get path name to current directory or folder
+7k Golang : Auto-generate reply email with text/template package
+5.1k Golang : Experimental emojis or emoticons icons programming language
+25.6k Golang : Find files by name - cross platform example
+11.5k Golang : Transform comma separated string to slice example
+10.5k Golang : Convert(cast) bigint to string
+32.7k Golang : Integer is between a range
+18k Golang : Convert seconds to human readable time format example
+27.8k Golang : JQuery AJAX post data to server and send data back to client example