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.9k Golang : Convert lines of string into list for delete and insert operation
+11.8k Golang : Decompress zlib file example
+18.9k Golang : Get host name or domain name from IP address
+5.7k Golang : Shuffle array of list
+21.8k Golang : Match strings by wildcard patterns with filepath.Match() function
+5.5k Fix yum-complete-transaction error
+24.2k Golang : GORM read from database example
+5.7k Golang : Use NLP to get sentences for each paragraph example
+10.9k Golang : Web routing/multiplex example
+12.4k Golang : Pass database connection to function called from another package and HTTP Handler
+5.3k Golang : If else example and common mistake
+9.4k Golang : Quadratic example