Jump to content




CryptX - Symmetric Encryption Algorithm

api lua utility

2 replies to this topic

#1 Corona

  • Members
  • 18 posts

Posted 12 April 2016 - 09:55 PM

Hello, CC community!

I've just recently come back to writing programs for computercraft again and thought it would be a good idea to start off simple.

The API I've made is an object-based encryption algorithm, which works symmetrically, meaning, that you use one password to de- and encrypt. I know it is neither efficient, nor uncrackable (I know someone can do this.), but it works, and that's the main point. "Quod erat demonstrantum", as romans would say.

The API has 4 methods;
--creates the object and sets an encryption password. The password is optional, as it can be set later with initialize()
function CryptX:craft( password )

--Initializes the seed and everything else to begin de/encryption
function CryptX:initialize( password )

--Encrypts a string and returns an encoded table.
function CryptX:encrypt( str )

--Decrypts the table created by encrypt() and returns the original string. Please note, that the password used for decryption must match the on used to encrypt the message.
function CryptX:decrypt( tEncr )

It can be downloaded via pastebin, but it needs another API to function; Stringmanager, also found below. Load both APIs via os.loadAPI() and you're good to go!

PS: Saving can be achieved by serializing the table. I have to streamline the whole thing a bit, a table isn't the best solution, honestly!

CryptX: http://pastebin.com/rNEUDtJf
StringManager: http://pastebin.com/U0GDqWzv

#2 Anavrins

  • Members
  • 775 posts

Posted 12 April 2016 - 11:32 PM

So here's my thought on this...
It's not the first time people has made ciphers using the built-in math.random function, I myself did that once, but there are few problems with it.
Mainly, it's not cryptographically secure, it uses something called linear congruential generator, which is not at all suited for crypto purposes.
In general stream-ciphers are by themselves a random number generator, which you manually XOR with your plaintext, so depending on a system dependent generator doesn't sound like a good idea.
Example another script could replace the math.random function so that it produces an even weaker sequence.

Edited by Anavrins, 12 April 2016 - 11:33 PM.


#3 Corona

  • Members
  • 18 posts

Posted 13 April 2016 - 05:00 AM

A good point indeed, but as I mentioned, this thing wasn't meant to be secure, or even remotely useful, it was more of a little warm-up for the things I want to do in the future, which all (thank goodness) don't involve encryption, as I clearly am not familiar enough with cryptography to achieve a level of quality for cipher algorithms, I would be satisfied with.

I will keep in mind what you said though (:





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users