Is there a way to find the next item in a random sequence?

I know that there was such a program:

#include <iostream>
#include <string>


int main() {
    const std::string alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    std::string temp = "1234567890";
    srand(MAGICNUMBER);
    for (int i = 0;; ++i) {
        for (int j = 0; j < 10; ++j)
            temp[j] = alphabet[rand() % alphabet.size()];
        std::cout << temp << std::endl;
    }
}

Basically, a random 10-character string generator.

I also know that the generated line 124660967 was "2lwd9JjVnE". Is there a way to find what MAGICNUMBER, or at least the next line in a sequence?

Brute force will be painful given the time it takes to create one such sequence, but I have information about the compiler used (if that helps?): It was 64-bit g ++ 4.8 for Linux.

UPD . Finding the next item will already be very helpful; can I do this at reasonable intervals (especially without seed)?

+4
3

, rand(), , , , , .

rand() , : x1 = (a * x0 + c)% m. a, c m, , ( , ). , 32 . .

, pRNG, , 10 , : 2lwd9JjVnE. , rand(), 32- x, :

x % 62 = 54
(x1 = (a*x + c) % m) % 62 == 11
(x2 = (a*x1 + c) % m) % 62 == 22
(x3 = (a*x2 + c) % m) % 62 == 3
(x4 = (a*x3 + c) % m) % 62 == 61
(x5 = (a*x4 + c) % m) % 62 == 35
(x6 = (a*x5 + c) % m) % 62 == 9
(x7 = (a*x6 + c) % m) % 62 == 47
(x8 = (a*x7 + c) % m) % 62 == 13
(x9 = (a*x8 + c) % m) % 62 == 30

, 2 ^ 32 ( 32- ). , , , RNG 32- , , .

, , , 124660967 * 10 , , . m. (period - 124660967*10).

+3

, . @chux , ++.

, . .


, , ( ), , rand() .

+2

, , , .

srand, , , , , , , .

0

Source: https://habr.com/ru/post/1628013/


All Articles