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
+30.5k Golang : How to redirect to new page with net/http?
+7.8k Golang : Mapping Iban to Dunging alphabets
+9.2k Golang : How to capture return values from goroutines?
+6.1k Fontello : How to load and use fonts?
+6.6k Golang : Calculate diameter, circumference, area, sphere surface and volume
+5.4k PHP : Hide PHP version information from curl
+4.9k Which content-type(MIME type) to use for JSON data
+7.5k Golang : Convert source code to assembly language
+52.8k Golang : How to get struct field and value by name
+9.7k Javascript : Read/parse JSON data from HTTP response
+11k Golang : Get UDP client IP address and differentiate clients by port number
+6.5k Golang : How to search a list of records or data structures