ARFilter Plug-in: Random True/False Generator
This program is in direct response to seeing a number of requests on the ARSList over the years for a way to randomly perform a given action (send a survey, etc.). This is a very simple arfilter plug-in that returns a value, true or false, based on a probability expressed as the denominator of a fraction. For example, if you wanted a true/false value returned, with a 1 in 10 chance that the return value is True, you would pass the number 10 to the plug-in.
The T/F value is returned using the following logic:
- Seed the prng device with some data
- Generate 4 bytes of random data, using OpenSSL's RAND_pseudo_bytes
- convert the 4 random bytes into a 32-bit unsigned integer (values range from 0 to 4,294,967,295)
- Calculate the modulus of the random bytes using the value passed to the plug-in
- Return True if the modulus is 0, otherwise return false
Project Information
| License | BSD License |
| Code Repository | Subversion repository available at http://svn.arswiki.org/arfprng |
| Project Owner | Axton Grams |
Practical Applications
- Randomly generate email surveys
- Randomly open a survey dialog if user closes or confirms the closure of their own request
