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 my Raspberry Pi, I get a completely different list.
I guess the RNG is different.
Is there a way to "unify" the way numbers being generated or to implement an algorithm that will generate the same numbers?
def genKeys(number, seed, length):
rng = random.Random(seed)
seq = "abcdefghijklmopqrstuvxyzABCDEFGHIJKLMOPQRSTUVWXYZ1234567890 +-.,!%/?<>^_[]#$"
key = open("key.txt", "w")
for i in range(0, number):
gen = ""
n = 0
while n < length:
charGen = rng.choice(seq)
gen += charGen
n = n + 1
key.write("%s\n" % (gen))
key.close()
Background: These keys will be used as One-Time-Use keys to encrypt messages.
Aucun commentaire:
Enregistrer un commentaire