This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Emma's profile picture

CRYPTUM :: Password Based File Encrypter

Started by Emma, 30 September 2014 - 08:47 PM
Emma #1
Posted 30 September 2014 - 10:47 PM
Cryptum

Hello again! Some of you recall my original file encrypter that shifted all of the character's bytes one forward. Now, while this is effective to obfuscate code, it doesn't provide any real protection. So, I created cryptum! It uses a unique file encryption algorithm (Which I dreamed up in math class :3).

Usage:


> crypt <fileIn> <fileOut> <e/d for encrypt/decrypt>


EG.
> crypt secretstuff nothingimportant e						
Password to save with: ****					
			  
(Password to save with comes after you press enter)


Download: TcFQUxxt
Edited on 30 September 2014 - 08:48 PM
0099 #2
Posted 18 October 2014 - 05:24 PM
Well, when it comes to encryption and you must write the code manually, I think this is the best possible solution. And the coolest fact about this is its extendability. Basically, you can insert any possible PRNG instead of math.random - and it will work. So, if you have something cryptographically secure within easy reach, just use it! And if you haven't, but still want to increase security, you can re-create the standart math.random (that is Linear congruential generator), but with your own coefficients.

Btw, interpreting a password like THAT is really a unique idea, but I believe it's insecure in some way. Just because the value of bseed is a bit predictable. I think you should do it in the honest way (that means, bseed should contain the same amount of information). To do this you should concatenate the numbers not in decimal digits, but in binary:

bseed = 0
for i=1,#pass do
   bseed = bseed*256+string.byte(pass:sub(i,i))
end

Also, instead of having a small pstr (you introduced this variable because of "invalid value" error, right?) at line 17 you should take a remainder of division by 256 before calling string.char:

endt = endt..string.char((string.byte(tte:sub(i,i))+(tArgs[3]=="d" and shift or -1*shift))%256)
So now pstr = 255 and everything is working.
Edited on 18 October 2014 - 03:50 PM