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
+48k Golang : Convert int to byte array([]byte)
+11.8k Golang : How to detect a server/machine network interface capabilities?
+5.1k Golang : micron to centimeter example
+32.6k Golang : Copy directory - including sub-directories and files
+27.5k Golang : Convert CSV data to JSON format and save to file
+4.8k Unix/Linux : How to pipe/save output of a command to file?
+8.3k Golang : Reverse text lines or flip line order example
+7k Nginx : Password protect a directory/folder
+18.8k Golang : convert int to string
+8.2k Golang : Check from web if Go application is running or not
+16.1k Golang : Generate universally unique identifier(UUID) example
+19.3k Golang : Populate dropdown with html/template example