mirror of
https://github.com/jech/galene.git
synced 2024-11-22 16:45:58 +01:00
Implement -user option in password generator.
This commit is contained in:
parent
f5de94cf3e
commit
50ba4d97f7
1 changed files with 21 additions and 5 deletions
|
@ -6,6 +6,7 @@ import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"flag"
|
"flag"
|
||||||
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
@ -18,13 +19,20 @@ func main() {
|
||||||
var iterations int
|
var iterations int
|
||||||
var length int
|
var length int
|
||||||
var saltLen int
|
var saltLen int
|
||||||
flag.IntVar(&iterations, "iterations", 4096, "number of iterations")
|
var username string
|
||||||
flag.IntVar(&length, "key length", 32, "key length")
|
flag.StringVar(&username, "user", "",
|
||||||
flag.IntVar(&saltLen, "salt", 8, "salt length")
|
"generate entry for given `username`")
|
||||||
|
flag.IntVar(&iterations, "iterations", 4096, "`number` of iterations")
|
||||||
|
flag.IntVar(&length, "key", 32, "key `length`")
|
||||||
|
flag.IntVar(&saltLen, "salt", 8, "salt `length`")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
if len(flag.Args()) == 0 {
|
if len(flag.Args()) == 0 {
|
||||||
flag.Usage()
|
fmt.Fprintf(
|
||||||
|
flag.CommandLine.Output(),
|
||||||
|
"Usage: %s [option...] password...\n",
|
||||||
|
os.Args[0])
|
||||||
|
flag.PrintDefaults()
|
||||||
os.Exit(2)
|
os.Exit(2)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +55,15 @@ func main() {
|
||||||
Iterations: iterations,
|
Iterations: iterations,
|
||||||
}
|
}
|
||||||
e := json.NewEncoder(os.Stdout)
|
e := json.NewEncoder(os.Stdout)
|
||||||
|
if username != "" {
|
||||||
|
creds := group.ClientCredentials{
|
||||||
|
Username: username,
|
||||||
|
Password: &p,
|
||||||
|
}
|
||||||
|
err = e.Encode(creds)
|
||||||
|
} else {
|
||||||
err = e.Encode(p)
|
err = e.Encode(p)
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Encode: %v", err)
|
log.Fatalf("Encode: %v", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue