Search code examples
pythondjangorandom

Django - make_random_password method, is it truly random?


I am using the following method to create a random code for users as part of a booking process:

 User.objects.make_random_password()

When the users turn up at the venue, they will present the password.

Is it safe to assume that two people won't end up with the same code?


Solution

  • No, it's not safe to assume that two people can't have the same code. Random doesn't mean unique. It may be unlikely and rare, depending on the length you specify and number of users you are dealing with. But you can't rely on its uniqueness.