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
+15.7k Golang : Validate hostname
+10.8k Golang : How to delete element(data) from map ?
+28.2k Golang : Decode/unmarshal unknown JSON data type with map[string]interface
+14.2k Golang : convert rune to unicode hexadecimal value and back to rune character
+30.1k Golang : Get and Set User-Agent examples
+15.1k Golang : Submit web forms without browser by http.PostForm example
+8.2k Golang : Sort words with first uppercase letter
+19k Golang : Delete duplicate items from a slice/array
+13.8k Golang : Query string with space symbol %20 in between
+18.9k Golang : convert int to string
+7.7k Golang : Rot13 and Rot5 algorithms example
+4.2k Detect if Google Analytics and Developer Media are loaded properly or not