How to generate pseudorandom numbers?

Good time of day.

From articles on Habre it is possible to derive a single formula:
9e6864dcca7a4149839e7d57f679c824.png

But when using this formula I have is not quite what I need.

Therefore, how to generate any pseudo-random number algorithm ? (Like in Python at random.randint(arg1, arg2) or, as in Java when you use new Random().nextInt(100)

P. S: In the labels specified Python and Java, but really you can use any, preferably C-like, language
July 2nd 19 at 17:16
6 answers
July 2nd 19 at 17:18
Judging by Your comment to the answer You several not understand the essence of his question.

Any, repeat, any, randomly chosen number will be in some sequence, and the sequence itself will be based on some formula.

I deeply doubt that anyone will ever be able to get a completely random number, because any accident is unknown rule!

A separate question - how much do predictable the appearance chisle in Your sequence. This is necessary to conduct all searches.

Take, for example, the rand() function from any programming language. It will generate a pseudorandom number based on a timestamp in unixtime. How much is it predictable? Hmm, I think not less than 100%. Well, it turns out that knowing the approximate time of the start of the function rand(), say, up to 1 minute, we can get exactly the same pseudorandom number. Well, ie, now, this need to dig.

Let's assume that we pulled a list of companies from the register in Moscow and took them ORGN. Next, our function generates unixtime and from it we subtract the bin, and the last two ceftri in unixtime and bin should be the same(for example, selecting the bin can be any). What have we achieved? Knowing the function rand() we can generate exactly the same second pseudo-random number. You may now argue that let's take the same bin and repeat the procedure. At this point, I want to ask You a question: from whom do we build defense? The attacker is the Creator of system knows about it 100%? I think any protection in this case is simply meaningless.

You have to make to its formula for generating some kind of unexpected behavior that will differ from what is in the standard implementation. Is this some bin, birthdays of Your colleagues, the ID of the users in the VC, etc., the External attacker this feature is not known.

Does Your pseudo-random number cislem more or less random? Hmm... Great question... In this place again, remembering what a coincidence.
Whether it will allow to increase the security of the system? I think is because the attacker is unknown to the algorithm, although this is to some extent bad.

Summarizing all the above - to make Your series of pseudo-random numbers more random, you need to the formula of its generation to add a number from another number to something random. Also highly recommend the resulting pseudo-random number to test for simplicity, if You are going to use as the value to generate the secret key for the GOST or RSA
"I deeply doubt that anyone will ever be able to get a completely random number, because any accident is unknown rule!" - quantum processes? AFAIK, there was something on the fact that any sequence of results cannot possibly belong to matter. - Everette56 commented on July 2nd 19 at 17:21
But Yes, you need an iron :-) - Everette56 commented on July 2nd 19 at 17:24
July 2nd 19 at 17:20
Almost all random number generators generate exactly the sequence, where, knowing the initial number (seed), you can repeat the entire sequence. To generate truly random numbers using hardware devices or the accumulation of entropy of events (delay between keystrokes, mouse movements).
Code that uses Java provided in the same article as the code that restores seed in two consecutive results of nextInt.
July 2nd 19 at 17:22
Hmm....
Whether skis do not go, whether I......
Read:
Therefore, how to generate any pseudo-random number algorithm ?

Well look, I need to generate a random number as its algorithm. And in this equation I have some sequence, so I need a solution without any sequence

These are two opposite concepts.
Pseudo-random - obey the law (formula generated).
Random, respectively, no.

Therefore, if you need, after all, random and so no one would know, then use the dynamic parameters of the environment (for a particular case - the parameters from the OS): the temperature sensor, the amount of free/used disk space, the amount of used/free memory, number and process IDs, etc.

The selection criteria parameters:the rapidly and unpredictably changing value in time and independent of the algorithm in the code generator, not available from outside.

HaShirim parameters with timestamp by any algorithm and take the Kauai part of the resulting hash.
IMPORTANT! The options for hashing should not be publicly available: no external queries with an INN, OGRN and GISMETEO! )

The easiest option: 68747470733a2f2f6661726d382e737461746963 Took the picture and made any changes with it, and then saved in the data stream, took any bit or more. The picture generated based on external factors and never put into the source code of the algorithm.
July 2nd 19 at 17:24
But when using this formula I have is not quite what I need.

For example?
Well look, I need to generate a random number as its algorithm. And in this equation I have some sequence, so I need a solution without any sequence - Everette56 commented on July 2nd 19 at 17:27
: this sequence will be difficult to distinguish from random numbers + you can take one of "true" random number and using it as a seed to generate a pseudorandom sequence. That would get really "strong" (pseudo)random number usually are hardware generators of entropy. If you are just interested in this topic can read the Chapter about the PRNG in the book "Practical cryptography" by Niels Ferguson and Bruce Schneier. - Everette56 commented on July 2nd 19 at 17:30
take the system time - helga.Jacobson53 commented on July 2nd 19 at 17:33
July 2nd 19 at 17:26
No, I'm talking about the algorithm, not about a ready-made solution - Everette56 commented on July 2nd 19 at 17:29
July 2nd 19 at 17:28
take a sequence of numbers from 0 to n, take one step any Prime number p > n/2, and remove it from the sequence each number with the number p in a circle.
But here sequence. You and I understand the need to be "created" and not elected.
Polecat, what's wrong with the setting, because the cards from the deck autosorting also choose, and nothing, such a choice is considered to be random. A so on the basis of the system time. White noise or radio frequency. Or service random.org. If your algorithm will be tested diehard - mark this, it will be interesting ;)

Find more questions by tags JavaProgrammingPythonAlgorithms