在Java中反转LCG

时间:2019-05-26 01:03:27

标签: java arrays sorting random cryptography

我正在尝试获取产生此随机数的原始值。

Random rand = new Random(295);
int nextInt = 0;
for (int n = 0; n < 78801 + 1; n++) {
    nextInt = rand.nextInt(500000);
}
System.out.println(nextInt);//499429

值(499429)由种子(295)产生,它是第78801个nextInt。根据所附的链接,我已经做了很多研究,LCG是可逆的。我该如何在Java中反转它,以便仅使用种子值和输出我将获得第n个值?

Making a customizable LCG that travels backward and forward

Reversible pseudo-random sequence generator

pseudo random distribution which guarantees all possible permutations of value sequence - C++

Reversible Linear Congruential Generator

Cracking a linear congruential generator

Cracking Random Number Generators - Part 1

Reverse engineering the seed of a linear congruential generator

Predicting the next Math.random() in Java

Inverse function of Java's Random function

0 个答案:

没有答案