Building a Login GUI app in Python with encrypted credentials saving functionality

Building a Login GUI app in Python with encrypted credentials saving functionality

Building a GUI from scratch for a desktop-based application is always a pain when it comes to programming languages and frameworks. Things get complicated for newbies when combining desktop and web applications for delivering automation.

Once the desktop part is built we will have to connect it to web, and in case it requires filling in credentials we will have to fill them again and again for testing and using , can we reduce this laborious effort ? , yes we can do it by encrypting the credentials locally on the desktop location.

To solve all the above mentioned problems rapidly, one of highest recommended libraries will be PySimpleGUI and Cryptography.

Let us make a simple GUI Desktop Application looks like below :

GUI Application look

For every PySimpleGUI program there are 5 sections :

1. Import

2. Layout

3. Window

4. Event Loop (optional)

5. Close

To install the PySimpleGUI and Cryptography libraries we will use the below set of commands (Note:pip package installer and python binary should be installed by default) :

1. For PySimpleGUI installation :

pip install pysimplegui

Pysimplegui installation

2. For Cryptography package installation :

pip install cryptography

Once the two packages are successfully installed , lets start to build application with the below code:

  1. This GUI package provides you with multiple themes of different colours and visulalizations, to explore the ones that are available :

once you run this , you will see the below output:

PySimpleGUI themes

Yes this is the collection availble for GUI themes , lets use the Dark Amber theme to make our application, and make a layout:

2. Once the layout is ready, let us build the window and also save the credentials entered in an encrypted format , In the below code, we are using fernet object which is a library to convert our plaintext user credentials to cipher text. Converting these credentials will make sure that they are safe.We are using a key to encrypt these credentials and they are later stored in bledygo.y

We have built it in such a way that it can store the credentials of a single user, this is not for multiple users. In case you are looking to update the credentials , just delete the bledygo.y file.

Full code of this application can be accessed over here.

To run this application we will use the following command :


Layout for the GUI App

To save the credentials

Auto fill will automatically populate the input tabs with encrypted credentials.

Happy Coding everyone !!

For any further Queries or anything related to Autmation via Python or DevOps you can DM me on Linkedin or instagram id=acanubhav94.

Special credits to my team interns : Kishan and Pratik.