[Mono-list] Random seeding on different machines
Edward Ned Harvey (mono)
edward.harvey.mono at clevertrove.com
Tue Oct 4 14:02:05 UTC 2016
> From: Mono-list [mailto:mono-list-bounces at lists.dot.net] On Behalf Of Matt
> Calder
>
> We are seeing differences in the output of Random.Next,
> Random.NextDouble when run from the same seed but on different
> machines. I am wondering if this is expected.
The implementation of the non-crypto random functions is not to be assumed. That is - you should not use it for crypto purposes. You will often have predictable results, but you should not count on the results being predictable, as the underlying implementation is not in the spec, so the implementation is subject to change.
If you require a predictable result from a starting seed, you're looking for a DRBG, or PRNG, with a known standard implementation. There are some NIST standards out there that define such DRBG's, and there are some implementations of those available in some crypto libraries such as bouncycastle, but it would basically be a research topic to figure it all out if you want to go that way. The really simple way to do it, assuming you want a predictable result, and you're not concerned with security, is to just put an AES class into CBC mode, and give in a seed for the key and IV. Wrap it in a CryptoStream. You'll have predictable random output, fairly low cost.
More information about the Mono-list
mailing list