Posted 13 August 2015 - 01:24 PM
After failing to get the other encryption APIs on the forums to work (probably me being stupid), I wrote my own. While I agree it's generally a bad idea to make your own encryption algorithms, I figured all the secure encryption algorithms out there didn't start by someone going "let someone else do it, they're better at it", so gave it a go.
Install: pastebin get BQZfkgFk encryption
By using dofile() to load this, you get the table with the functions encrypt() and decrypt() inside. The usages are as follows:
Encryption.encrypt()
- by serializable, this means something that can be serialized using textutils.serialize() (no functions or coroutines, even in nested tables)
Encryption.decrypt()
- if the key is equal to the key which encrypted the value initially, what this returns will be equal to the thing passed to encrypt()
In an effort to make the cipher transmittable over modems and able to be put on pastebin, the cipher will be a string of hexadecimal characters [A-F, 0-9]. In addition, to add security to the cipher, random sections of garbage characters are added after each 'block' (5 character section). This means the cipher is significantly longer than the value put in (2.4x average iirc).
This is meant to be quick: 890KB/s on my computer. The reason I wrote my own key generator rather than using math.random is because math.random is very slow, and takes its performance down hugely. There's still some optimisation to do, such as localising some of the math functions, but I want to see if it's secure enough to use first.
I'd really appreciate it if people find issues with this (security issues/bugs). It seems there are some crypto-know-it-all people on the forums so it would be great to have some feedback on this.
Install: pastebin get BQZfkgFk encryption
By using dofile() to load this, you get the table with the functions encrypt() and decrypt() inside. The usages are as follows:
local encryption = dofile( "path_to_API" )
Encryption.encrypt()
string cipher = encryption.encrypt( any_serializable_value value, string/number key )
- encrypts the value given with the key given- by serializable, this means something that can be serialized using textutils.serialize() (no functions or coroutines, even in nested tables)
Encryption.decrypt()
any_serializable_value value = encryption.decrypt( string cipher, string/number key )
- decrypts the cipher given with the key given- if the key is equal to the key which encrypted the value initially, what this returns will be equal to the thing passed to encrypt()
In an effort to make the cipher transmittable over modems and able to be put on pastebin, the cipher will be a string of hexadecimal characters [A-F, 0-9]. In addition, to add security to the cipher, random sections of garbage characters are added after each 'block' (5 character section). This means the cipher is significantly longer than the value put in (2.4x average iirc).
This is meant to be quick: 890KB/s on my computer. The reason I wrote my own key generator rather than using math.random is because math.random is very slow, and takes its performance down hugely. There's still some optimisation to do, such as localising some of the math functions, but I want to see if it's secure enough to use first.
I'd really appreciate it if people find issues with this (security issues/bugs). It seems there are some crypto-know-it-all people on the forums so it would be great to have some feedback on this.