import (
"crypto/rand"
"crypto/sha512"
+ "encoding/base64"
"encoding/hex"
"flag"
"fmt"
)
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")
+ s := flag.Int("s", 1<<16, "Space cost, number of hash-sized blocks")
+ t := flag.Int("t", 3, "Time cost, rounds")
+ p := flag.Int("p", 1, "Number of threads")
saltHex := flag.String("salt", "", "Salt, hexadecimal, optional")
passwd := flag.String("passwd", "", "Password")
flag.Usage = func() {
if err != nil {
panic(err)
}
- fmt.Println(hex.EncodeToString(balloon.H(sha512.New, []byte(*passwd), salt, *s, *t, *p)))
+ fmt.Println("Salt:", hex.EncodeToString(salt))
+ h := balloon.H(sha512.New, []byte(*passwd), salt, *s, *t, *p)
+ fmt.Println("Hash:", hex.EncodeToString(h))
+ fmt.Printf(
+ "Encoded: $balloon$h=sha512,s=%d,t=%d,p=%d$%s$%s\n",
+ *s, *t, *p,
+ base64.RawStdEncoding.EncodeToString(salt),
+ base64.RawStdEncoding.EncodeToString(h),
+ )
}