DEV Community

Cover image for An Encryption Algorithm
Dhairya K.
Dhairya K.

Posted on

An Encryption Algorithm

The CLI I designed

Hi everyone! This is my first blog post, and it's about an encryption algorithm I've written, and I've named it Polynomial Encryption.

The idea

I don't really have a clear memory of how I came upon the idea, but it doesn't matter.

The original idea was creating an algorithm that took O(n!)O(n!) to break for a key size nn . That isn't the case anymore, but it is O(kn)O(k^n) , and kk is a large enough constant(97) that it exceeds the factorial for all reasonable key sizes.

The Algorithm (a brief overview)

For encryption it takes inputs TEXT and KEY, converts them into arrays TEXT and KEY by mapping each diagraph(two characters) to a unique value according to a mapping BASE97. I chose 97 because 97 is the smallest prime greater than 95, which is the number of useful characters on a QWERTY keyboard.

It then combines TEXT and KEY into a list of points, DATA.

It then performs Lagrange Interpolation on these points to create a polynomial and oversamples it to create data which can be used in combination with the original key to recover (decrypt) the data.

I won't go into too much of the math here, because it is quite a hefty amount. However, it is pretty simple, considering that me, a 13-yr old, can understand it.

Open Source Nature

Being a fan of Linux and Godot, it was only natural that I published the code for free. It is MIT license, and you can modify the code if you so wish.

You can ask me for changes if you wish - please do not pester me as I also have school and so will get around to making changes ASAP but not immediately.

I am aware that files cannot be encrypted yet - I plan to do this later as this will require a LOT of work - so please don't request this

My GitHub repo can be found here

Thank You!!

I'll try to explain the math in a separate post if possible, and until then, bye!

Top comments (0)