4

Is there a way to have more secure randomization that is very hard to reproduce?

I have tried letting the user enter a seed to create more secure passwords so its harder to repeat the same seed, but i was wondering if there was a better/automatic way to do this?

import random
import string

LENGTH = input("How long do you want your password?: ")
SEED = input("Seed? (The more random the better)")
GENLIST = list(string.ascii_letters + string.digits)
if SEED != "":
    random.seed(SEED)

try:
    PASSWORD = ""
    for i in range(int(LENGTH)):
        PASSWORD += GENLIST[(random.randint(0, 61))]
    print()
    print(PASSWORD)
except TypeError:
    print("Integer not entered")
input()
Ramzisnot2
  • 41
  • 1

2 Answers2

3

Use os.urandom(), which reads from the corresponding device.

a small orange
  • 560
  • 2
  • 16
0

The documentation for random has has a section on this.

Warning   The pseudo-random generators of this module should not be used for security purposes. Use os.urandom() or SystemRandom if you require a cryptographically secure pseudo-random number generator.

I found this in a similar question with some more discussion on the topic.

Jordan
  • 1
  • 1