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
+9.6k Golang : Get current, epoch time and display by year, month and day
+9.2k Golang : Get all countries currencies code in JSON format
+7.3k Javascript : Push notifications to browser with Push.js
+6.4k Golang : Check if password length meet the requirement
+4.5k PHP : Extract part of a string starting from the middle
+10.7k Golang : Replace a parameter's value inside a configuration file example
+6.2k Golang : Calculate diameter, circumference, area, sphere surface and volume
+7.6k Javascript : How to check a browser's Do Not Track status?
+16.8k Golang : How to save log messages to file?
+46k Golang : Encode image to base64 example
+6.9k Golang : Null and nil value
+11.1k Golang : Byte format example