本文整理匯總了Golang中github.com/howeyc/gopass.GetPasswdMasked函數的典型用法代碼示例。如果您正苦於以下問題:Golang GetPasswdMasked函數的具體用法?Golang GetPasswdMasked怎麽用?Golang GetPasswdMasked使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了GetPasswdMasked函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: setup
func setup() {
var dir string
var username string
var password []byte
fmt.Println("Setup")
fmt.Println("--------------------")
fmt.Println("Bitte gib deine CampusOffice daten ein.")
fmt.Println("Deine Zugangsdaten werden verschlüsselt auf deinem Computer abgelegt.")
fmt.Printf("MatrNr: ")
fmt.Scanln(&username)
fmt.Printf("Passwort: ")
password = gopass.GetPasswdMasked()
for !login(string(username), string(password)) {
fmt.Println("Falche MatrNr oder falsches Passwort!")
fmt.Printf("MatrNr: ")
fmt.Scanln(&username)
fmt.Printf("Passwort: ")
password = gopass.GetPasswdMasked()
}
fmt.Println("Erfolgreich eingeloggt")
db.set_encrypted_setting(e, "username", username)
db.set_encrypted_setting(e, "password", string(password))
fmt.Println("Bitte gib den Speicherort an, an dem deine iCal exportiert werden soll.")
fmt.Println("Beispiele:")
fmt.Println("Windows: C:\\Users\\Benutzer\\Dropbox")
fmt.Println("Linux: /home/Benutzer/Dropbox")
fmt.Printf("Speicherort: ")
fmt.Scanln(&dir)
_, err := os.Stat(dir)
for err != nil {
if os.IsNotExist(err) {
log.Print(err)
fmt.Printf("Der Speicherort %s existiert nicht.\n", dir)
fmt.Println("Bitte gibt einen gültigen Speicherort an")
} else {
fmt.Println("Es ist ein Fehler aufgetreten.")
fmt.Println("Bist du sicher, dass du Zugriffsberechtigungn auf diesen Ordner hast?")
}
fmt.Printf("Speicherort: ")
fmt.Scanln(&dir)
_, err = os.Stat(dir)
}
db.set_setting("dir", dir)
db.set_setting("setup", "1")
fmt.Println("Setup abgeschlossen")
}
示例2: Login
func Login(args []string, opts map[string]interface{}) {
user := &userInfo{CurDir: "/"}
if len(args) == 3 {
user.Bucket = args[0]
user.Username = args[1]
user.Password = args[2]
} else {
fmt.Printf("ServiceName: ")
fmt.Scanf("%s\n", &user.Bucket)
fmt.Printf("Operator: ")
fmt.Scanf("%s\n", &user.Username)
fmt.Printf("Password: ")
b, err := gopass.GetPasswdMasked()
if err == nil {
user.Password = string(b)
}
}
if _, err := NewFsDriver(user.Bucket, user.Username,
user.Password, user.CurDir, 10, nil); err != nil {
fmt.Fprintf(os.Stderr, "failed to log in. %v\n", err)
os.Exit(-1)
}
// save
conf.UpdateUserInfo(user)
conf.Save(confname)
}
示例3: getAndVerifyMaster
func getAndVerifyMaster(master string) string {
// prompt for a master password if necessary
if len(master) == 0 {
// get master password from environment, or from keyboard
if s := os.Getenv("LETMEIN_MASTER"); s != "" {
master = s
} else {
fmt.Printf("Master password: ")
master = string(gopass.GetPasswdMasked())
if len(master) == 0 {
fmt.Fprintf(os.Stderr, "master password is required")
os.Exit(1)
}
}
}
// validate the master password
if len(master) < minMasterLength || len(master) > maxMasterLength {
fmt.Fprintf(os.Stderr, "master password must be between %d and %d characters\n", minMasterLength, maxMasterLength)
os.Exit(1)
}
for _, r := range master {
if r < minChar || r > maxChar {
fmt.Fprintf(os.Stderr, "master password contains an illegal character\n")
os.Exit(1)
}
}
return master
}
示例4: SetupDb
// SetupDb creates a new database or opens an existing one at a given directory.
// This will prompt the user to set a password if the database is being created.
func SetupDb(path string) (*Db, error) {
imageDb, err := imagedb.NewDb(path)
if err != nil {
return nil, err
}
res := Db{imageDb, sync.RWMutex{}, filepath.Join(path, "config.json"), Config{}}
saveConfig := false
if res.loadConfig() != nil {
saveConfig = true
}
if res.config.PasswordHash == "" {
fmt.Print("Setup new password: ")
pass := gopass.GetPasswdMasked()
res.config.PasswordHash = HashPassword(string(pass))
saveConfig = true
}
if res.config.MaxFileSize == 0 {
res.config.MaxFileSize = DefaultMaxFileSize
saveConfig = true
}
if res.config.MaxUploadsPerHour == 0 {
res.config.MaxUploadsPerHour = DefaultMaxCountPerHour
saveConfig = true
}
if saveConfig {
if err := res.saveConfig(); err != nil {
return nil, err
}
}
return &res, nil
}
示例5: ReadPassword
// ReadPassword reads password from standard input without echoing the characters.
// If mask is true, each chracter will be represented with astericks '*'. Note that
// this only works as expected when the standard input is a terminal.
func (s *Shell) ReadPassword(mask bool) string {
fmt.Fprint(s.writer, s.prompt)
if mask {
return string(gopass.GetPasswdMasked())
}
return string(gopass.GetPasswd())
}
示例6: AskCredentials
func (adc *ADC) AskCredentials() {
fmt.Print("ADC username: ")
fmt.Scanf("%s\n", &adc.username)
fmt.Print("ADC password: ")
adc.password = string(gopass.GetPasswdMasked())
}
示例7: GetPasswd
func GetPasswd() string {
fmt.Printf("Password: ")
p, err := gopass.GetPasswdMasked()
if err != nil {
log.Fatal(err)
}
return string(p)
}
示例8: PasswordMasked
// Password prompt with mask.
func PasswordMasked(prompt string, args ...interface{}) string {
fmt.Printf(prompt+": ", args...)
var buf, err = gopass.GetPasswdMasked()
if err != nil {
return ""
}
s := string(buf[0:])
return s
}
示例9: ReadPassword
// ReadPassword reads password from standard input without echoing the characters.
// If mask is true, each character will be represented with asterisks '*'. Note that
// this only works as expected when the standard input is a terminal.
func (s *Shell) ReadPassword(mask bool) string {
if s.showPrompt {
s.Print(s.prompt)
}
if mask {
return string(gopass.GetPasswdMasked())
}
return string(gopass.GetPasswd())
}
示例10: getPassword
func getPassword() []byte {
passFromEnv := os.Getenv("SCONSIFY_PASSWORD")
if passFromEnv != "" {
fmt.Println("Reading password from environment variable SCONSIFY_PASSWORD.")
return []byte(passFromEnv)
}
fmt.Print("Password: ")
return gopass.GetPasswdMasked()
}
示例11: input_SrcSeed
func (this *MergeAccount) input_SrcSeed() string {
fmt.Printf(this.infoStrings[this.languageIndex][MA_INFO_INPUT_SOURCE_SEED])
input := gopass.GetPasswdMasked()
if publicdefine.VerifySAddress(string(input)) == nil {
return string(input)
}
return ""
}
示例12: input_SrcSeed
func (this *AccountInfoPayment) input_SrcSeed() string {
fmt.Printf(this.infoStrings[this.languageIndex][AIP_INFO_INPUT_PRIVATE_SEED])
input := gopass.GetPasswdMasked()
if publicdefine.VerifySAddress(string(input)) == nil {
return string(input)
}
return ""
}
示例13: PasswordMasked
// PasswordMasked prompt with mask.
func PasswordMasked(prompt string, args ...interface{}) string {
fmt.Printf(prompt, args...)
b, err := gopass.GetPasswdMasked()
if err != nil {
panic(err)
}
return string(b)
}
示例14: main
func main() {
fmt.Print("Email/username: ")
user := readLine()
fmt.Print("Password: ")
pass, err := gopass.GetPasswdMasked()
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
fmt.Println()
fmt.Println("Authenticating...")
sess, err := fbmsgr.Auth(user, string(pass))
if err != nil {
fmt.Fprintln(os.Stderr, "Failed to login:", err)
os.Exit(1)
}
fbid := promptChat(sess)
fmt.Print("Destination filename: ")
file := readLine()
fmt.Println("Downloading messages...")
var actions []map[string]interface{}
actionChan, errChan := sess.FullActionLog(fbid, nil)
for action := range actionChan {
actions = append(actions, action.RawFields())
fmt.Printf("\rGot %d actions...", len(actions))
}
fmt.Printf("\rTotal of %d actions...\n", len(actions))
if err := <-errChan; err != nil {
fmt.Fprintln(os.Stderr, "Fetch error:", err)
}
// Sort the actions chronologically.
for i := 0; i < len(actions)/2; i++ {
actions[i], actions[len(actions)-(i+1)] = actions[len(actions)-(i+1)], actions[i]
}
encoded, err := json.MarshalIndent(actions, "", " ")
if err != nil {
fmt.Fprintln(os.Stderr, "Serialization failed:", err)
os.Exit(1)
}
if err := ioutil.WriteFile(file, encoded, 0755); err != nil {
fmt.Fprintln(os.Stderr, "Failed to write file:", err)
os.Exit(1)
}
}
示例15: promptForString
func promptForString(field string, r io.Reader, show bool) (result string, err error) {
fmt.Printf("Please enter %s: ", field)
if show {
_, err = fmt.Fscan(r, &result)
} else {
var data []byte
data, err = gopass.GetPasswdMasked()
result = string(data)
}
return result, err
}