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
+18.3k Golang : Compare floating-point numbers
+5k Golang : Compound interest over time example
+9.4k Golang : How to delete element(data) from map ?
+5.2k Golang : Create new color from command line parameters
+5k Fontello : How to load and use fonts?
+12.8k Golang : Chunk split or divide a string into smaller chunk example
+4.5k Swift : Convert string array to array example
+10.8k Golang : Determine if time variables have same calendar day
+25.9k PHP : Count number of JSON items/objects
+19.2k Golang : Pipe output from one os.Exec(shell command) to another command
+9.3k Golang : Allow Cross-Origin Resource Sharing request
+17.7k Golang : Read input from console line