Skip to main content
Challenges Secure and weak generators
Cryptography Easy CSPRNG Solves: 4

Secure and weak generators

Author: CyberSamSU
Points
25

Generators are divided into two types. A simple PRNG (for example, the random module, LCG, Mersenne Twister) works fast and gives statistically nice numbers, but an attacker who has seen a few outputs can recover its internal state and calculate both the future and the past.

A cryptographic generator (CSPRNG), however, relies on the operating system's entropy, and it is practically impossible to recover the internal state from its outputs. In Python, this is the secrets module and os.urandom. The rule is simple: a password, token, key, nonce, session ID — only from a CSPRNG.

Part 1. Theoretical choice

Of the 7 codes below, three are cryptographically secure, the rest are vulnerable. Determine the numbers of the secure ones.

Code 1:

parol = str(random.randint(100000, 999999))

Code 2:

token = secrets.token_hex(16)

Code 3:

x = (1103515245 * x + 12345) % 2**31
return x

Code 4:

kalit = os.urandom(32)

Code 5:

random.seed(int(time.time()))
sid = random.getrandbits(128)

Code 6:

sid = hashlib.md5(str(time.time()).encode()).hexdigest()

Code 7:

kalit = secrets.SystemRandom().getrandbits(256)

Part 2. Practical verification

The attached file contains two sequences: A and B. Both consist of numbers from 0 to 231 and look "random". But one is obtained from a vulnerable LCG.

Hint: in an LCG, if x = (a·x + c) mod 2k and a, c are odd, the least significant bit of the numbers (even/odd) strictly alternates. That is, even, odd, even, odd... This can be checked in a few lines.

Assemble the answer in the following format — first the numbers of the secure codes in ascending order, then the letter of the vulnerable sequence: BAYROQ{PRNG_xavfsiz_<r1>_<r2>_<r3>_zaif_<harf>} (the letter is a capital A or B).

Attached files
ketma_ketliklar.txt Log in to download
SHA-256 checksums
ketma_ketliklar.txt: a297c81e32633ee4710f95851a98b51d0c1dce5d5c6b7e0f987569b290771b2d
Theory: learn the topic
Hints 3
Opening a hint reduces the points you get for solving this challenge.
Hint 1 −2 pts Log in
Hint 2 −5 pts Log in
Hint 3 −7 pts Log in
To submit a flag, log in.

First solvers

1. Лазиз 04.10.2026
2. Mirjaxon Qaxxarov 27.10.2026
3. Odam 06.11.2026
4. Doston Allayarov 12.11.2026