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.2k Javascript : Detect when console is activated and do something about it
+10.7k Golang : Forwarding a local port to a remote server example
+29k Golang : Convert an image file to []byte
+6.7k Findstr command the Grep equivalent for Windows
+4.5k Unix/Linux : How to open tar.gz file ?
+9.3k Golang : Bubble sort example
+6.5k Golang : Test if an input is an Armstrong number example
+4.8k Golang : Experimental emojis or emoticons icons programming language
+5.5k How to let Facebook Login button redirect to a particular URL ?
+8.9k Golang : Underscore string example
+6.6k Swift : Convert (cast) String to Double
+3.5k Facebook : How to place save to Facebook button on your website