X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=cmd%2Fballoon%2Fmain.go;h=948f4bfe49c1c73e95a255b55d56c5391bd15654;hb=bcc78124b96707003eedb6a2e1e98db3f2aeab5c;hp=65d27a11e8d9f59e554f885b15d64e62250c88ba;hpb=0da8173d31c47459cef75d5ff17bc89be0598a19;p=balloon.git diff --git a/cmd/balloon/main.go b/cmd/balloon/main.go index 65d27a1..948f4bf 100644 --- a/cmd/balloon/main.go +++ b/cmd/balloon/main.go @@ -1,6 +1,6 @@ /* balloon -- Balloon password hashing function -Copyright (C) 2016-2019 Sergey Matveev +Copyright (C) 2016-2021 Sergey Matveev This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -21,20 +21,26 @@ package main import ( "crypto/rand" "crypto/sha512" + "encoding/base64" "encoding/hex" "flag" "fmt" "io" + "os" "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") + 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() { + fmt.Fprintf(os.Stderr, "balloon -- Strengthen password with Balloon+SHA512\n\n") + flag.PrintDefaults() + } flag.Parse() var salt []byte var err error @@ -47,5 +53,13 @@ func main() { 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), + ) }