开发者

How do you use a non-number as a seed in an RNG?

How would you use, say, the string "abc" as the seed of an RNG? Would you change it into 0x616263, or 123, or开发者_运维百科 hash it with sha1 (or some other hash), or something else?


Hashing with a high-quality hashing algorithm seems like the best solution. However, depending on how many bits you have to seed with, you might have to use only a part of the generated hash. This shouldn't be a problem if you use a cryptographically strong algorithm that has well-distributed outputs.


I'm assuming

  • you want a repeatable pseudorandom sequence
  • your RNG expects an integer.

In this case, the answer is: it doesn't matter.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜