I wan't to make 1000 passwords and give them to users. Passwords contain 6 digits - they look like random 6 digits.
When user comes there is no information besides this password, and I want to validate it.
I can walk through the database to look for this password, but I want to decrease the difficulty of this operation from O(N) to O(1), where N is the number of passwords.
Is there any method of generating 1000 'random-likely' passwords with simple ways of check them?
UPD: Right now I'm thinking of making encryption. For example (Python)
key = 'top_secret'
N = 1000
passwords = [encrypt(i, key) for i in range(N)]
def check(s):
try:
return int(decrypt(s, key))<1000
except ValueError:
return False
But this I suppose there is a better solution
UPD2: 3 digits and 6 digits are just for example. They may be 64 and 128 digits