Trying secrets (Python) to Generate Password

In my spare time, I want to explore more about Cyber Security. This time I will try how good secrets module. I use secrets.choice to generate my password. I use the recipe that is provided by Python documentation, here.

Photo by Chris Ried on Unsplash

I use small code to generate the list of my passwords and also small code to check the duplication. Here my python script to generate the code:

Here the code to check the password list:

I will try generate some numbers of password to check how strong the generated password. I think this naive method good for the first try how strong the module. If you not find any duplication in this method, doesn’t mean it is strong. You will need another method to check the strength. I will use 100, 1000, 100000, 1000000 and 1000000000 numbers of password. Let’s start!

100 passwords

You need to check the output, the output is False. It mean not have any duplication. I want to bring the execution time too, because it will bring long time for more numbers. It is also prove that I not get the wrong list when run Let’s check this out.

1000 passwords

Seems still good until 1000 password. Let’s check the another.

100000 passwords
1000000 passwords

Great! 100000 and 10000000, the number that “enough” number to test, still not bring any duplication. Let’s check the bigger number!

The 1000000000, I can’t produce now. I need to improve my code to parallel or multi-thread things. The current implementation will very long time to achieve. :( I will give you an update if I can run that.


I want to give “little” summary. We can assume that the secret module strong enough. We still need more advance method to check the method. For many data generation will update soon. Thank you for read this.

Backend Developer — Focus at Microservices and Cloud Computing

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store