Hacker News new | past | comments | ask | show | jobs | submit login

It's not random. It's not a generator. You are just returning a different representation of the seed you already have.



> It's not random. It's not a generator.

No, it's a pseudorandom generator. It's a key attribute of a cryptographically secure function like SHA256 that its output is indistinguishable from random bits.

> You are just returning a different representation of the seed you already have.

I'm returning a function of the seed, yes. That's the whole point of a seeded PRNG: that seed(x); rng(); rng(); rng() will always return the same sequence of results. This is used for example in procedural generation, to ensure that a dungeon level or map chunk is always generated the same way (a cool hack, then, is to just store the seed instead of the level itself, and rerun the level-generation algorithm with the seed when one wishes to regenerate the level). In such an application one wants the appearance of randomness, but with repeatability.

Which was what the original post asked for.

What I suggested is not secure for generating keys or for other cryptographic purposes.


Yes, if you fed the output of a SHA256 calculation back into the algorithm repeatedly you would get a pseudo-random stream. I think that is what you intended. Your original post was not clear on that and I thought you were just taking a value and returning a mutation of it using some unknown "reseed" and "value".


By that definition, no PRNGs are 'R' or 'G'.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: