From: Sergey Matveev Date: Sat, 5 Oct 2019 08:03:44 +0000 (+0300) Subject: Do not require salt passing, generate it X-Git-Tag: v1.1.0~4 X-Git-Url: http://www.git.cypherpunks.ru/?p=balloon.git;a=commitdiff_plain;h=3524ab4193dc8d7ad50c76edb0aac02c062918ee Do not require salt passing, generate it --- diff --git a/cmd/balloon/main.go b/cmd/balloon/main.go index 7ba57af..0c737c9 100644 --- a/cmd/balloon/main.go +++ b/cmd/balloon/main.go @@ -1,10 +1,12 @@ package main import ( + "crypto/rand" "crypto/sha512" "encoding/hex" "flag" "fmt" + "io" "go.cypherpunks.ru/balloon" ) @@ -13,10 +15,17 @@ func main() { s := flag.Int("s", 1<<18, "Space cost, number of hash-sized blocks") t := flag.Int("t", 2, "Time cost, rounds") p := flag.Int("p", 4, "Number of threads") - saltHex := flag.String("salt", "deadbabe", "Salt, hexadecimal") + saltHex := flag.String("salt", "", "Salt, hexadecimal, optional") passwd := flag.String("passwd", "", "Password") flag.Parse() - salt, err := hex.DecodeString(*saltHex) + var salt []byte + var err error + if len(*saltHex) == 0 { + salt = make([]byte, 8) + _, err = io.ReadFull(rand.Reader, salt) + } else { + salt, err = hex.DecodeString(*saltHex) + } if err != nil { panic(err) }