Skip to content Skip to sidebar Skip to footer

Generating The Same "random Numbers" With A Seed In Python On Two Different Computers

I am trying to generate the same list of random sequences using the function 'genKeys'. Using the same seed, I will get the same list, but only on my Laptop. Running this code on m

Solution 1:

For the purposes of generating encryption keys, Python's random.Random is not an appropriate choice; its underlying algorithm, Mersenne Twister, is not a cryptographic random generator.

Instead, there are so-called key derivation functions (KDFs, also called salted hashes) that take a seed as well as a salt to generate an encryption key. The salt is necessary in order to mitigate precomputation attacks. And if the seed is relatively easy to guess (e.g., the seed is a password), some KDFs deliberately take noticeable time and/or memory to compute, to mitigate dictionary attacks.

If your goal is to send messages securely between two computers (e.g., between a Raspberry Pi and a PC), it's hard to help you further since the right solution depends on your needs. For example, there are established protocols to set up a secure channel between two computers, including Transport Layer Security (TLS), J-PAKE, and others. One-time password algorithms include hash-based one-time passwords (HOTP), time-based one-time passwords (TOTP), and others. Security protocols in particular are far from trivial to implement, and are best accessed in Python via a dedicated Python package.

Post a Comment for "Generating The Same "random Numbers" With A Seed In Python On Two Different Computers"