Building Image to Encryption

Inspiration

I cam across an article about Cloudflare's wall of lava lamps. The idea that they were using the unpredictable patterns of lava lamps to generate random numbers for encryption was interesting. To need something analog, something from the natural world for digital encryption was also kind of ironic.

This concept inspired me to create my own application, where I could turn images into encryption tools. Creating secure passwords is kind of a hassle, and turning images into passwords seemed like a cool and easy way to do it. Plus, there's something poetic about using personal images to protect personal data.

Learning

Building this project pushed me to explore several new territories in web development and cryptography:

  1. Web Crypto API: I had to dive deep into browser-based cryptography. Learning how to properly implement AES-GCM encryption, handle key derivation, and manage initialization vectors was challenging.

  2. Image Processing: Working with the Canvas API to extract entropy from images taught me a lot about pixel manipulation and color data.

  3. TypeScript and React: While I was familiar with React, this project pushed me to use TypeScript more rigorously.

The Building Process

  1. First, I designed the image processing system. This involved analyzing color patterns and pixel distribution. I also created a project skeleton with all the necessary client-side routes and components.

  2. Next, I implemented the three main features incrementally:

    • Password generation came first, as it was the simplest application of the entropy
    • Public/private key generation followed, requiring more complex cryptographic operations
    • File encryption was the final and most challenging phase
  3. Throughout the process, I focused on creating a clean, intuitive UI

Challenges and Solutions

Technical Hurdles

The biggest technical challenge was implementing file encryption and decryption. I ran into several issues:

  1. File Metadata: Initially, I lost file metadata during encryption. Solving this required designing a custom header system to preserve filenames and MIME types alongside the encrypted data.

  2. Memory Management: Large files posed a challenge, especially when handling them in the browser. I utilized ArrayBuffers and implemented chunked processing for larger files.

In the future

  • Adding support for batch file processing
  • Implementing PWA (offline) features
  • Possibly expanding into a full-on password generator mobile app

Built With

Share this project:

Updates

Submission history