DelphiPythonPython GUIWindows

What You Need To Create A Secure Python Password Generator


Are you looking for a simple and powerful way to generate cryptographically strong passwords to secure your data, and build a nice GUI for it?

You can do it easily by combining Python4Delphi and secrets library, inside Delphi and C++Builder. Python4Delphi (P4D) is a free tool that allows you to execute Python scripts, create new Python modules and types in Delphi.

The secrets module is a Python built-in library to generate secure random numbers for managing secrets. The secrets module is used for generating cryptographically strong random numbers suitable for managing data such as passwords, account authentication, security tokens, and related secrets.

How can I run the Python secrets library in a Delphi Windows GUI app?

First, open and run our Python GUI using project Demo1 from Python4Delphi with RAD Studio. Then insert the script into the lower Memo, click the Execute button, and get the result in the upper Memo. You can find the Demo1 source on GitHub. The behind the scene details of how Delphi manages to run your Python code in this amazing Python GUI can be found at this link.


The secrets module provides functions for generating secure tokens, suitable for applications such as password resets, hard-to-guess URLs, and similar tasks.

To be secure against brute-force attacks, tokens need to have sufficient randomness. Unfortunately, what is considered sufficient will necessarily increase as computers get more powerful and able to make more guesses in a shorter period. In 2015, it is believed that 32 bytes (256 bits) of randomness is sufficient for the typical use-case expected for the secrets module.

How can we generate an eight-character alphanumeric Password, 16-bytes number of token bytes, and hex tokens?

We execute them many times to show you that all the output are unique, random, and hard to guess:



How can I generate a hard-to-guess temporary URL containing a security token suitable for password recovery applications?

We execute them many times to show you that all the output are unique, random, and hard to guess:



Congratulations, now you have learned how to run the secrets library using Python for Delphi to display it in the Delphi Windows GUI app! Now you can solve various real-world cryptographic tasks using the secrets library and Python4Delphi.

The secrets module is a built-in library by Python, so after installing Python, it would be on your system by default. However, you can check out the secrets documentation here: and

Check out Python4Delphi which easily allows you to build Python GUIs for Windows using Delphi:

Related posts
DelphiPythonPython GUIWindows

This Is How To Automatically Parse RSS Feeds In Your Apps

Learn PythonPythonPython GUIVideos

Create Your First GUI With Python Using 5 Lines of Code

Learn PythonPythonPython GUIVideos

How To Make A Standalone Python EXE Executable

DelphiPythonPython GUIWindows

3 Ways To Create Enterprise-Grade Graphics Using The Seaborn Library

Leave a Reply

Your email address will not be published. Required fields are marked *