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
+4.6k Chrome : How to block socketloop.com links in Google SERP?
+22.5k Golang : Strings to lowercase and uppercase example
+12.5k Golang : Sort and reverse sort a slice of bytes
+36.8k Golang : Converting a negative number to positive number
+27.9k Golang : Move file to another directory
+30.3k Golang : Generate random string
+9k Golang : Serving HTTP and Websocket from different ports in a program example
+8.4k Android Studio : Import third-party library or package into Gradle Scripts
+29.3k Golang : Login(Authenticate) with Facebook example
+7k Golang : Use modern ciphers only in secure connection
+21.6k Golang : Setting up/configure AWS credentials with official aws-sdk-go
+7.7k Golang : Scan files for certain pattern and rename part of the files