Encrypt Secret Messages to Be Unlockable Under the Right Environmental Conditions

This device by Tim C encrypts secret messages with keys derived from environmental data.

We all love the idea of secret messages encrypted in ways that are only decipherable through elaborate means — escape rooms and movies like The DaVinci Code and National Treasure rely almost entirely on that idea. Practical encryption in the real-world doesn’t work like that; a shared encryption key, for example, is just a boring string of random alphanumeric characters. This project from Tim C changes that by encrypting secret messages with keys derived from environmental data.

Modern encryption algorithms rely on cryptographic keys. You either have a single key that does both the encryption and decryption, or a two-key system with a public key for encryption and private key for decryption. It is kind of like the classic Caesar cipher, but with far more complex rules that change and those changing rules get stored as a key that looks like a random, meaningless set of characters.

In this case, encryption is done with a Vigenère cipher. But there is one very important caveat: the key isn’t randomly-generated and it isn’t a password chosen by the user. Instead, the device generates the key based on the readings from sensors. Those sensor readings include GPS coordinates, light brightness values (lux), and temperature/humidity/CO2. You could also use other kinds of sensors, if you were so inclined.

On the hardware side, that is all done using an Adafruit ESP32-S3 TFT Feather development board, with the appropriate Adafruit sensor modules connected. The ESP32 reads the sensor data and formats it as an SHA-256 hash for encryption and decryption.

If the sensor readings were truly analog with infinite resolution, decryption would essentially be impossible — you’d never replicate the exact environmental conditions necessary to duplicate the hash. But in this case, the individual sensors output digital data with relatively low resolution (say 0-125). When developing the algorithm for generating the hash, it is also possible to further reduce the recorded resolution.

In practice, that means it is possible to make it so decryption can still occur, even if the room is 1°F warmer or the GPS reading is imperfect.

I wouldn’t trust state secrets to it or anything, but this is a fun way to encrypt things. It seems especially well-suited to escape room puzzles, if you can tailor the sensors to the room’s theme.

Cameron Coward
Writer for Hackster News. Proud husband and dog dad. Maker and serial hobbyist. Check out my YouTube channel: Serial Hobbyism
Latest articles
Sponsored articles
Related articles
Latest articles
Read more
Related articles