forked from Vonage/gosrvlib
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[AUTOPR] Automatic updates (Vonage#239)
* Bump version * Update dependencies * Set recommended Argon2id default values and options. * Add comments, examples and benchmarks. --------- Co-authored-by: nicolaasuni-vonage <[email protected]>
- Loading branch information
1 parent
dcf43be
commit ec4d39a
Showing
11 changed files
with
349 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1.87.0 | ||
1.88.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package passwordhash_test | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
|
||
"github.com/Vonage/gosrvlib/pkg/passwordhash" | ||
) | ||
|
||
func ExampleParams_PasswordVerify() { | ||
opts := []passwordhash.Option{ | ||
passwordhash.WithKeyLen(32), | ||
passwordhash.WithSaltLen(16), | ||
passwordhash.WithTime(3), | ||
passwordhash.WithMemory(16_384), | ||
passwordhash.WithThreads(1), | ||
passwordhash.WithMinPasswordLength(16), | ||
passwordhash.WithMaxPasswordLength(128), | ||
} | ||
|
||
p := passwordhash.New(opts...) | ||
|
||
secret := "Example-Password-01" | ||
|
||
hash, err := p.PasswordHash(secret) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
ok, err := p.PasswordVerify(secret, hash) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
fmt.Println(ok) | ||
|
||
ok, err = p.PasswordVerify("Example-Wrong-Password-01", hash) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
fmt.Println(ok) | ||
|
||
// Output: | ||
// true | ||
// false | ||
} | ||
|
||
func ExampleParams_EncryptPasswordVerify() { | ||
opts := []passwordhash.Option{ | ||
passwordhash.WithKeyLen(32), | ||
passwordhash.WithSaltLen(16), | ||
passwordhash.WithTime(3), | ||
passwordhash.WithMemory(16_384), | ||
passwordhash.WithThreads(1), | ||
passwordhash.WithMinPasswordLength(16), | ||
passwordhash.WithMaxPasswordLength(128), | ||
} | ||
|
||
p := passwordhash.New(opts...) | ||
|
||
key := []byte("0123456789012345") | ||
|
||
secret := "Example-Password-02" | ||
|
||
hash, err := p.EncryptPasswordHash(key, secret) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
ok, err := p.EncryptPasswordVerify(key, secret, hash) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
fmt.Println(ok) | ||
|
||
ok, err = p.EncryptPasswordVerify(key, "Example-Wrong-Password-02", hash) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
fmt.Println(ok) | ||
|
||
// Output: | ||
// true | ||
// false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.