cmd/balloon/main.go | 13 +++++++++++-- diff --git a/cmd/balloon/main.go b/cmd/balloon/main.go index 3576c4b14144d3e2166706b320408283d4e606935e5d05f03ecdb53925f35714..ba9c14eb922716971cfe62f5e921ae0c93712e0cc7d90bd8c22a195556b014d4 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) }