Inspiration

Having written many Flask apps at hackathons, I'm familiar with how easy it can be to forget to secure the responses. Often, the difficulty of implementing this in a truly secure way can outweigh potential benefits, so these web apps remain insecure. For this reason, I created InfraCrypt!

What it does

InfraCrypt is a Python command-line module that allows users to securely encrypt the responses in a Flask app through keys generated by the random behaviour of a hardware module.

InfraCrypt first parses through the file to ensure it is a Flask app and extracts any responses present. It then gets the key by calculating the distance between the ultrasonic sensor and the cardboard wing. This key is encrypted and then sent back to InfraCrypt, which uses it to encrypt the corresponding response using the AES-256 protocol.

Once the encryption is done, the original Flask app is replaced with one that has the encrypted responses, and a JSON file with the decryption information is generated for whichever frontend the developer wants to use.

How I built it

InfraCrypt was written in Python using cryptography libraries and setuptools to make it a package. Pytest was used for testing and Pylint was used for linting.

For the hardware, an ESP32 microcontroller was used to interface with the sensors. An infrared sensor was used to detect motion, an ultrasonic sensor was used to find the distance, and a servo motor was used to move the cardboard wing, all connected on a breadboard. The coding for this was all done with the Arduino IDE, using the WiFi capabilities.

GitHub Actions were also set up, with a CI pipeline being setup for Pylint, Pytest, and CodeQL to ensure that the code quality was high, the code passed tests continually, and that there were no serious security vulnerabilities in the code.

Challenges I ran into

Since I did not have many building materials for the course of the hackathon, I had some trouble finding a good way to build a structure that could hold the motor and the wing that would pivot on the servo motor. However, I was able to find a carboard box, and along with some paper clips I could connect it all into a relatively secure build.

Further, I had never worked with the ESP32 and I only had limited experience with Arduino before. For this reason, understanding Serial and how to get and write information to and from the sensors was quite a learning curve. Still, with the hackathon resources and my research, I understood how to get valuable information from them.

Accomplishments that I'm proud of

This was my first hackathon project with such a high volume of hardware. At first, I was worried that I was being a little too ambitious and thought I should maybe scale it down a bit. However, it ended up working and I understood a lot more about sensor communication through this, which I am quite proud of.

What I learned

I learned a great deal about programming with sensors and interfacing with WiFi through a microcontroller. Further, it was my first time making a Python CLI application and a Python package, so these were also quite high achievements for me.

What's next for InfraCrypt

Improving the hardware prototype and increasing the types of responses InfraCrypt can encrypt. Possibly also adding frontend decryption for React and Angular.

Built With

Share this project:

Updates