Skip to content

Commit

Permalink
Properly seed nonce generator
Browse files Browse the repository at this point in the history
  • Loading branch information
Acconut committed Aug 9, 2022
1 parent 2be7e08 commit 46f08cf
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion transloadit.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ var DefaultConfig = Config{
type Client struct {
config Config
httpClient *http.Client
random *rand.Rand
}

// ListOptions defines criteria used when a list is being retrieved. Details
Expand Down Expand Up @@ -89,6 +90,7 @@ func NewClient(config Config) Client {
client := Client{
config: config,
httpClient: &http.Client{},
random: rand.New(rand.NewSource(time.Now().UnixNano())),
}

return client
Expand All @@ -101,7 +103,7 @@ func (client *Client) sign(params map[string]interface{}) (string, string, error
}
// Add a random nonce to make signatures unique and prevent error about
// signature reuse: https://github.com/transloadit/go-sdk/pull/35
params["nonce"] = rand.Int()
params["nonce"] = client.random.Int()
b, err := json.Marshal(params)
if err != nil {
return "", "", fmt.Errorf("unable to create signature: %s", err)
Expand Down

0 comments on commit 46f08cf

Please sign in to comment.