✨ Offer password generation and query
This commit is contained in:
@@ -26,6 +26,11 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
crand "crypto/rand"
|
||||
"math"
|
||||
"math/big"
|
||||
"math/rand"
|
||||
|
||||
"github.com/alecthomas/kong"
|
||||
)
|
||||
|
||||
@@ -38,6 +43,14 @@ type app struct {
|
||||
}
|
||||
|
||||
func main() {
|
||||
// When we need simple randomization (not cryptographically secure one), we should at least start
|
||||
// with some non-default-seed.
|
||||
seed, err := crand.Int(crand.Reader, big.NewInt(math.MaxInt64))
|
||||
if err != nil {
|
||||
panic("cannot initialize rand: " + err.Error())
|
||||
}
|
||||
rand.Seed(seed.Int64())
|
||||
|
||||
var app app
|
||||
ctx := kong.Parse(&app)
|
||||
|
||||
@@ -50,32 +63,6 @@ func main() {
|
||||
|
||||
ctx.FatalIfErrorf(ctx.Run(&app))
|
||||
|
||||
//if *genPassword {
|
||||
// // math.rand is not secure. For determining the number of digits in a password
|
||||
// // it should suffice, though.
|
||||
// rand.Seed(time.Now().UnixNano())
|
||||
// pwLen := 32
|
||||
// pw, err := pwgen.Generate(pwLen, rand.Intn(pwLen/2), 0, false, true)
|
||||
// if err != nil {
|
||||
// panic(err)
|
||||
// }
|
||||
// hash, err := bcrypt.GenerateFromPassword([]byte(pw), 0)
|
||||
// if err != nil {
|
||||
// panic(err)
|
||||
// }
|
||||
//
|
||||
// fmt.Printf("Password: %s\n", pw)
|
||||
// fmt.Printf(" Hash: %s\n", hash)
|
||||
// return
|
||||
//} else if *hashPassword != "" {
|
||||
// hash, err := bcrypt.GenerateFromPassword([]byte(*hashPassword), 0)
|
||||
// if err != nil {
|
||||
// panic(err)
|
||||
// }
|
||||
// fmt.Println(string(hash))
|
||||
// return
|
||||
//}
|
||||
|
||||
//c := LoadConfig(*configFile)
|
||||
//
|
||||
//h := &webdav.Handler{}
|
||||
|
||||
Reference in New Issue
Block a user