Skip to content

Commit

Permalink
bcrypt: add easy example
Browse files Browse the repository at this point in the history
  • Loading branch information
Lars Gohr committed Sep 8, 2019
1 parent 9756ffd commit 9bf4791
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions bcrypt/bcrypt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,3 +241,14 @@ func TestNoSideEffectsFromCompare(t *testing.T) {
t.Errorf("got=%q want=%q", got, want)
}
}

func ExampleBcrypting() {
password := []byte("mypassword")
securedPassword, err := GenerateFromPassword(password, DefaultCost)
if err != nil {
panic(err)
}

fmt.Println(CompareHashAndPassword(securedPassword, password))
// Output: <nil>
}

0 comments on commit 9bf4791

Please sign in to comment.