package main
import (
+ "crypto/rand"
"crypto/sha512"
"encoding/hex"
"flag"
"fmt"
+ "io"
- "cypherpunks.ru/balloon"
-)
-
-var (
- 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")
- passwd = flag.String("passwd", "", "Password")
+ "go.cypherpunks.ru/balloon"
)
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", "", "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)
}