Add salt size flag to pw.
This commit is contained in:
parent
cbed8afc08
commit
073dbe547a
16
README.md
16
README.md
|
@ -310,7 +310,21 @@ Individual backends have their options described in the sections below.
|
|||
|
||||
### Files
|
||||
|
||||
The `files` backend implements the regular password and acl checks as described in mosquitto. Passwords should be in PBKDF2 format (for other backends too), and may be generated using the `pw` utility (built by default when running `make`) included in the plugin (or one of your own). Check pw-gen dir for `pw` flags.
|
||||
The `files` backend implements the regular password and acl checks as described in mosquitto. Passwords should be in PBKDF2 format (for other backends too), and may be generated using the `pw` utility (built by default when running `make`) included in the plugin (or one of your own). Passwords may also be tested using the [pw-test package](https://github.com/iegomez/pw-test).
|
||||
|
||||
Usage of `pw`:
|
||||
|
||||
```
|
||||
Usage of ./pw:
|
||||
-a string
|
||||
algorithm: sha256 or sha512 (default "sha512")
|
||||
-i int
|
||||
hash iterations (default 100000)
|
||||
-p string
|
||||
password
|
||||
-s int
|
||||
salt size (default 16)
|
||||
```
|
||||
|
||||
For this backend passwords and acls file paths must be given:
|
||||
|
||||
|
|
12
pw-gen/pw.go
12
pw-gen/pw.go
|
@ -7,20 +7,18 @@ import (
|
|||
"github.com/iegomez/mosquitto-go-auth/common"
|
||||
)
|
||||
|
||||
// saltSize defines the salt size
|
||||
const saltSize = 16
|
||||
|
||||
func main() {
|
||||
|
||||
var algorithm = flag.String("a", "sha512", "algorithm (sha256 or default: sha512)")
|
||||
var HashIterations = flag.Int("i", 100000, "hash iterations (default: 100000)")
|
||||
var algorithm = flag.String("a", "sha512", "algorithm: sha256 or sha512")
|
||||
var HashIterations = flag.Int("i", 100000, "hash iterations")
|
||||
var password = flag.String("p", "", "password")
|
||||
var saltSize = flag.Int("s", 16, "salt size")
|
||||
|
||||
flag.Parse()
|
||||
|
||||
pwHash, err := common.Hash(*password, saltSize, *HashIterations, *algorithm)
|
||||
pwHash, err := common.Hash(*password, *saltSize, *HashIterations, *algorithm)
|
||||
if err != nil {
|
||||
fmt.Errorf("error: %s\n", err)
|
||||
fmt.Printf("error: %s\n", err)
|
||||
} else {
|
||||
fmt.Println(pwHash)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue