woocommerce / wc-api-ruby

A Ruby wrapper for the WooCommerce API.
MIT License
69 stars 74 forks source link

Reduce chance of nonce collisions #9

Closed danielhoey closed 9 years ago

danielhoey commented 9 years ago

Woocommerce only requires nonces only need to be unique within a 15 minute window. We use the modulo of the floating point time so that our nonces cycle every 15 minutes and add (PID * 15 mins) to ensure that no process on the same machine is using the same range of numbers. The only way a collision can occur is if processes on different machines have the same PID and start the request at the same time (within microseconds).