From 3524ab4193dc8d7ad50c76edb0aac02c062918ee Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Sat, 5 Oct 2019 11:03:44 +0300 Subject: [PATCH] Do not require salt passing, generate it --- cmd/balloon/main.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) 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) } -- 2.44.0