DNA-cryption

DNA-cryption

7 devlogs
14h 55m
•  Ship certified

A simple web program for encoding data into DNA. Not very practical for data privacy, but fun, I hope.
You can export your message as an image of a DNA strand, with your message encoded to DNA molecules.
You can also upload files, but they must be under 250 bytes.

The title is a double pun, by the way. Do you get it?

Timeline

Ship 1

1 payout of shell 343.0 shells

Rohan the Codebreaker (my code)

about 1 month ago

Rohan the Codebreaker (my code) Covers 7 devlogs and 14h 55m

Most files are way too big to be reasonably converted to a good image.
I probably should have thought of that already, but I'm fixing it now, so it's probably file. I mean fine.

Uploading files can still be done, but now there's a convenient text field for just encoding a simple message.
I've also added a way to change the number of Bézier curves in your spline.t

Update attachment

My goal this whole time has been to encode DATA into DNA, and so far, there's not much data coming in nor out. But I fixed it!

Now, it's possible to input a file from your computer and then get an image of DNA from it!
You can do everything from this helpful little panel here.

I did this with some simple-ish file reading code, where it reads the file as an array of bytes, and then returns a base 4 string.

It looks like I'm almost done with my project, as everything's working pretty well. But there are definitely things I could do to make it even better, and from here on out, changes will likely be small or simple improvements.

Thanks for reading up to here!
As always, check things out with more images on my repository devlogs!

Update attachment

Bézier curves are not uniform in their movement. Some parts of the curve have a higher velocity than others, which makes the spacing between molecules uneven when interpolating linearly over one. Trying to fix this issue led me down a rabbit hole online about arc-length parametrization during which I learned some new techniques and math to help me with handling Béziers.

The method I used in the end was one I found on a stack exchange conversation. It goes as follows:

  • Use numerical integration to find a time-to-arclength map.
  • Invert the map using binary search and linear interpolation for precision.
  • Use this map as a lookup table and update it when points change.

With this, I am able to make equally spaced DNA parts!

Since Hackclub only allows one attachment per devlog, check out a demonstration in my repository's devlog folder.

Update attachment

C2, Here we come!
Now, when editing the points of each curve, the continuity is preserved, leaving the DNA strand looking smooth. I may change this to only C1 if it proves too restricting, but for now it looks pretty good!
There is still an issue with sharp corners. When there is one, some artifacts are left on the corner, making it look ugly. I'll look into that later.

I assigned colors to each DNA molecule, ATCG, and made it draw to the screen when given a string (pun intended) of DNA.
Here is a demonstration with the string ACTGATAGCTA. As you can see, only one side of the DNA shows the data inputted, because both sides must match.

The DNA is still bendable however you want, of course.

Update attachment

In order to get the local coordinate spaces on the curves, I had to add functions for finding them, which involved taking some derivatives! Luckily, I like derivatives.

The user should be able to input a file of a reasonable size and get the data as a DNA encoding. A string of text would be boring, so I plan to make the output an image of the DNA strand. I want the DNA string to be movable, adding customization to the output.

The simplest way to do that, I think, will be with editable Bézier splines. I learned about Bézier curves a few months ago and I am fascinated by them and their other cousin curves, so I thought this would be a fun application for them.

In this update I made a quick and simple implementation of an editable Bézier curve with four movable points.

From here I'll add more general spline editing and probably focus on the actual data encoding functionality LAST.

Thanks for reading! <3