def calculer_next(previous, next): rand_nbr = Random() tab_to_return = [] for i in range(0, (2**16)+1): for j in range(0,2): t = 0 t = j t = t << 15 | previous t = t << 16 | i rand_nbr.srand(t) if (verif_next(rand_nbr.rand(), next)): tab_to_return.append(t) return tab_to_return
liste_des_possibles.append([]) for j in range(0, 5): if j == 0: nbr = val_possible else: nbr = liste_des_possibles[i][j-1] liste_des_possibles[i].append(inverse_modulaire * (nbr - 12345) % 2**32) i = i + 1 if debug_mode: print("Liste des possibles: ") #On renverse les listes, afin de pouvoir utiliser le dernier élément comme graine for i in range(0, len(liste_des_possibles)): liste_des_possibles[i] = liste_des_possibles[i][::-1] if debug_mode: print("{0}".format(liste_des_possibles[i])) #Utilisation de la graine rand_nbr.srand(liste_des_possibles[0][0]) #Calcul des clefs keys = [rand_nbr.rand(), rand_nbr.rand(), rand_nbr.rand(), rand_nbr.rand()] #On envoie le tout! try: reponse = server.query("validation/"+login, {'key' : keys}) print(reponse) except ServerError as e: print("Bad key for {0}".format(keys))