Team:Groningen/Software

iGEM Groningen 2019 :: Software

Software

To be able to read QR codes we set up to write our own software making use of Python and open source libraries. Our final software encompasses multiple functions as we adapted it through the development of our project. In simple terms, our scripts allow the user to perform the following functions:

  1. Generate a QR code from a message
  2. Encrypt the message within the QR code with a password
  3. Read the QR code
  4. Decrypt an encrypted QR code
  5. Generate a 3D model of a QR code to stamp on an agar plate
  6. Generate “gcode” based on a QR code to control a bioprinter to print a QR code

This method allows us to have more flexibility, and gives us the opportunity to optimize our program to our desired settings, as other publicly available QR code tools may not be able to.

This section of our wiki is designed to provide the reader a better idea of how QR code technology works, how we have designed our software to fit with our goals of privacy and security, and how our software allows all these tasks to be performed. First of all, a brief description of QR codes and how they encode data is outlined. Then the processes of our designed encryption and decryption mechanisms are explained.

An introduction to QR codes

QR codes operate by storing information in bytes, that is, blocks of zeros and ones that represent a character. However, the area of the QR code also contains further information such as:

  1. Error Correction data: that would allow the code, in case of damage, to still display its information.
  2. Positioning data: these are the iconic three big squares in the corners that allow the camera to determine where all other data points are.
  3. Format information: which tells the software what sort of information is stored in the QR code (text, images…)
QR Encoding 1
Different Sections in a QR code and their purpose (source: Datagenetics)

These codes have found their use in multiple applications, among which:

  1. Advertisement: to let people reach a link without typing it in
  2. Contact details: in business cards allows for quicker sharing of information
  3. Manufacturing lines: as they were originally created to track parts in a production line
  4. And many more fields! Keep your eyes open and you will see them in a day to day basis.

Encoding and Encryption Process

Before the data can be put into our petri dish we must first process it with the following steps:

  1. Encryption: using an algorithm to turn our message into a code that cannot be read, unless the user has access to the password.
  2. Encoding: Putting the previously encrypted message into QR code format

The encryption process consists of feeding a set of characters into an algorithm that will output a seemingly random set of characters. This process is done with the military standard AES (Advanced Encryption Standard) to ensure the best possible encryption levels. As an example, using the password “IGEM”, on the message “QRoningen” outputs:

“ViJ1Z/mUu3rpoUdik2+ZUczyQV864zg+uinrjeZ6d+s=”

Encrypted QR Code
The encrypted QR code with the encrypted message (Go ahead, scan it!)

Encryption, however, is not a simple task. There are always third parties trying to break the methods or find workarounds. That’s why it has been constantly evolving throughout the years. In the case of our software we use AES while adding the possibility of enabling salting, a process that makes it harder to guess the password. Although the salting process is implemented in the code, it could only be used in reality if we had a server to store the passwords in. Consequently, the future encryption process, and therefore the security of the QR codes, could be easily improved by adding more and more layers of security. However, while the passwords are not stored anywhere at the moment, the only way to decrypt the above QR code is with access to the password or many years of random trials.

Decoding and Decryption Process

This part of the process consists of repeating the previous steps backwards to obtain back the original message. As long as the password is available this process is not complicated since the computer handles all the computation and requires the “password” and the line of encrypted characters as shown in the interface of the script below:

Decryption of QR Code

However, to avoid having to type or copy paste these long strings of text we decided to implement the decryption mechanisms straight into a QR code scanner, to obtain the results shown below as output by the scanner:

QR code scanner
A screenshot from our scanner decrypting the QR code automatically during scanning

Therefore, somebody trying to read this QR code would get a seemingly meaningless message. However, while using our software, it is possible to actually read the message after inserting the right password. This makes it extremely easy to use.

Reading the biological QR code

When checking for the readability of our QR codes using existing software libraries we noticed that the contrast of the bacteria to the background wasn’t allowing the code to be read. This is due to QR codes being designed to be of a “darker” colour than their background, hence requiring more contrast. Therefore, to counteract this we decided to include a QR code reader in the software that alters the image colors to optimize the readability of our codes. Following is an example of the task the computer carries automatically, and if you try to scan this with your phone, you will notice that indeed the unaltered image is not able to be read, while with some distance adjustments the image on the right will be detected by the phone. However, We would want to note that the image filtering done by the computer could be improved drastically to accommodate for artifacts created by glare from the petri dish, and addition of better color filtering methods, as bacteria strains tend to vary in color.

QR modified with Software
Figure 7 – edited image from Biological QR code using our software to make it scannable

Preparing QR code to imprint plate

During our project we found two possible ways of imprinting the shape of a QR code in agar. These methods resulted in the creation of two automated software processes to reduce the time and effort it would take to send a biological QR code. This section will show these two methods:

3D Stamp

In attempts to make a defined enough image of a QR code on a plate we thought of using the classic method of stamping. To this purpose we needed a stamp in the shape of a QR code. However, carving it out is not an option as we needed automation to keep the possibility of using such a communicating method realistic. Therefore, we resorted to the use of a 3D printer, which brings another challenge to tackle: extruding a 2D image into a 3D file. Initially we did so by creating a 3D file in CAD software, but not happy with the scalability of the method we finally decided to develop a python script that would do so automatically in a matter of seconds. The results of this method can be seen in the following pictures.

Stamp 1
Stamp 2

Using these files it is possible to get a 3D printer to create the 3D model in under 2 hours to then proceed to do the stamping.

Gcode for bioprinter

The second method to bring the QR code into physical form is through the bioprinter we developed, which you can learn more about on our “hardware” page. This method involves the translation of a QR code image into code that the bioprinter will interpret as “spatial” operations to move the extruding tip to the desired locations.

The goal of this code was to be able to translate any QR code into gcode, therefore we developed a completely custom software capable of doing so. Gcode is the standard mode of controlling CNC machines, 3D printers and similar tools, however it is not a programming language that allows for functions and other operators to calculate variables, instead, it operates with strict commands that cannot be altered as the machine runs. Therefore, in order to write variable Gcode that adapts to any kind of QR code we developed a python script that takes any picture of a QR code and immediately outputs a Gcode file for the bioprinter.

Try out our code!

We have actually uploaded all our code into github for anybody to check out or try! It’s as easy as running one python script! Feel free to use it:

Github repository

Running the main script will prompt the user to input the desired password to encrypt and give the following possibilities:

Decryption of QR Code

Extra Software (IGEM Project Search Engine)

Among all the code we have created for our IGEM project we also thought about developing another tool for IGEM as we observed how difficult it was to really find other teams and what previous teams had worked on. This lead us to fetch all possible data from all IGEM teams dating back to 2008 and organize it to create “IGEMdb”, an easy to use tool that allows anybody to look up past IGEM projects based on filters like: abstract, project title, project track, team awards and more. We hope that this tool will help future igem teams brainstorm new possible projects, and maybe even let the IGEM organization be recognized for all the work that has been developed under it for more than 10 years.

Decryption of QR Code