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
+6.8k Android Studio : Hello World example
+9.4k Golang : Terminate-stay-resident or daemonize your program?
+13.1k Golang : How to calculate the distance between two coordinates using Haversine formula
+21k Golang : For loop continue,break and range
+13.2k CodeIgniter : "Fatal error: Cannot use object of type stdClass as array" message
+10.6k Golang : Interfacing with PayPal's IPN(Instant Payment Notification) example
+9.9k Golang : Ordinal and Ordinalize a given number to the English ordinal numeral
+4.7k MariaDB/MySQL : Form select statement or search query with Chinese characters
+18.7k Golang : convert int to string
+21.8k Golang : Upload big file (larger than 100MB) to AWS S3 with multipart upload
+17.6k Golang : Upload/Receive file progress indicator
+6.9k Mac OSX : Find large files by size