有没有办法从一系列数字中生成种子? [英] Is there a way to generate a seed out of a sequence of numbers?

查看:110
本文介绍了有没有办法从一系列数字中生成种子?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,如果java通过使用 23 作为种子生成伪随机序列: 9 3 2 5 6
,我该如何进行反转?即 23 9 3 2 5 6

For example if java produces the pseudorandom sequence: 9 3 2 5 6 by using 23 as a seed, how can I do the inverse? i.e. getting 23 out of the sequence 9 3 2 5 6.

或者我如何为某个序列?

Or how do I assign a seed for a certain sequence?

如果有数据库就很容易 - 只需为序列分配一个随机密钥

It is easy to do if there is a database - just assign a random key for the sequence

INSERT INTO SEQUENCE_TABLE VALUES (RANDOM_KEY, SEQUENCE)

但是,如果我不被允许使用数据库,是否有公式可以做这样的事情?

However if I'm not permitted to use a database, Is there a formula to do such a thing?

推荐答案

点是不可能的。 SecureRandom旨在特别加密强大,但一般来说,如果您正在编写随机数生成器,这是可能的或简单的,你做错了。

The point of random number generators is that this is impossible. SecureRandom is designed to be especially cryptographically strong, but generally speaking, if you're writing a random number generator and this is possible or easy, you're doing it wrong.

这就是说,内置Java可能不是不可能随机课。 (然而,SecureRandom是另一个故事。)但它需要数量惊人的数学。

That said, it's likely that it's not impossible with Java's built in Random class. (SecureRandom is another story, though.) But it will require staggering amounts of math.

更具体一点:如果存在多项式时间算法来做你想做的事情,对于某些特定的伪随机数生成器,那么根据定义它将失败链接的维基百科文章中描述的下一位测试,因为您可以预测将生成的下一个元素。

To be more specific: if a polynomial-time algorithm existed to do what you want, for some particular pseudorandom number generator, then it would by definition fail the "next-bit test" described in the linked Wikipedia article, since you could predict the next elements that would be generated.

这篇关于有没有办法从一系列数字中生成种子?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆