3 ms·
So is this a good PRNG? f(i) = SHA256(i + salt)
by olegkikin 9y ago
So is this a good PRNG?
f(i) = SHA256(i + salt)
- marvy 9y agoI don't know much about this stuff, but I think that this would be considered overkill (and thus too slow) if you don't need crypto-level randomness. But other than that it should be really good.
- grenoire 9y agoRandom, sure. Uniformly distributed? Not sure.
- AlexCoventry 9y agoMy understanding is that to the extent it's not uniformly distributed, that's viewed as a cryptographic vulnerability.
- Javantea_ 9y agoNo. A feature of a good PRNG is that it should not be predictable. If the salt is weak enough to be cracked, that PRNG can be reversed and predicted.
- __s 9y agoThe salt is the seed. Presumably initialized with /dev/random or whichever system entropy source is available. Any PRNG is weak if the seed is weak
- __s 9y agoDiscussion: https://crypto.stackexchange.com/questions/9076/using-a-hash-as-a-secure-prng https://crypto.stackexchange.com/questions/9076/using-a-hash... & http://xoroshiro.di.unimi.it http://xoroshiro.di.unimi.it makes reference to how on x86 cpus with AES one could get a very fast prng similar to how you're implying As a change of 1 bit in an input ideally flips half the bits of the output for a cryptographic hash, this scheme should work See also https://en.wikipedia.org/wiki/Fortuna_(PRNG) https://en.wikipedia.org/wiki/Fortuna_(PRNG)
- pvg 9y agoA PRNG usually doesn’t have parameters once seeded. What’s i in your scheme? If you’re asking if you can make a good PRNG out of cryptographic primitives, yes, that’s what happens in the bowels of OS CSPRNGs. But a bit more involved.