RndStrong -- generate a strongly random number (V7.1)
result = RndStrong(type, param)
This function can be used to generate cryptographically secure pseudo random numbers. Numbers returned by RndStrong() are much more random than those generated by Rnd() or RndF() both of which aren't appropriate for anything cryptography related.

RndStrong() can operate in two different modes: If you pass #INTEGER in type, it will return a single integer value that won't be smaller than 0 and won't be bigger than the integer passed in param (but it could be equal to param). If you pass #STRING in type, RndStrong() will generate a string of param random bytes, i.e. when passing #STRING, param specifies the desired length of the string.

Be warned that RndStrong() is very slow in comparison to Rnd() and RndF(). That is why you shouldn't call it too often but rather cache its results if you need lots of very random numbers. For example, you could call RndStrong() with type set to #STRING and param to 65536 to make it generate a string containing 64kb worth of random numbers. Once you've consumed those, you could call it again for more random numbers.

Also note that on AmigaOS 3.x and AROS RndStrong() currently falls back to Rnd() because those operating systems don't offer cryptography-proof randomizers.

type of data to generate; can be either #INTEGER or #STRING (see above)
greatest acceptable integer number if type is #INTEGER or the length of the string to generate if type is #STRING
random number(s) either as a string or integer value
Well, I cannot predict what value num will receive. I can only say that it will not be greater than 49 and not smaller than zero.

Show TOC