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

Encryption?

Started by Bobder22, 07 August 2012 - 03:14 AM
Bobder22 #1
Posted 07 August 2012 - 05:14 AM
So I had the genius idea of making a keycard locking door that would encrypt the password on the card, is there any way of doing this? And if so, how complicated would it be?
Bonum #2
Posted 07 August 2012 - 03:06 PM
If your door opens when the keycard is inserted, it doesn't matter if the password is encrypted. Someone could just copy the file on the keycard and use it in the door without breaking the encryption.

If you can keep the keycard safe, it would be a better idea to encrypt the password in the door computer. That way no one can read the password if they get access to the door code.

To do that, you need a function that turns a text string into nonsense, a hash function. In the door code, you would store the hashed password, and compare it to a hash of whatever is on the keycard.

As your hash function, you can probably find a lua version of the MD5 algorithm or something, it will be good enough. Or write your own, but if you are American, don't make it too good or you'll break the law! :P/>/>
Bobder22 #3
Posted 07 August 2012 - 04:17 PM
Alright, thanks for the help! ;)/>/>
Cranium #4
Posted 07 August 2012 - 05:26 PM
Can't help but think you could use math.randomseed() to accomplish this, but I have no idea how it would be implemented.
Noodle #5
Posted 07 August 2012 - 05:31 PM
Well, you could encrypt it so they can't understand the file.
Use textutils.serialize()
Cranium #6
Posted 07 August 2012 - 05:56 PM
Well, you could encrypt it so they can't understand the file.
Use textutils.serialize()
Or totally mess with them, and use both…
KFAFSP #7
Posted 07 August 2012 - 06:01 PM
Or you can use my adapted MD5 Hashing API! Checkout : http://www.computerc...rollers-and-os/

At the bottom of this post, there is a download link for file "hash".

Usage :


hash.md5.Calc(<PASSWORD>)

And math.randomseed() could be used for Hash-Salting. But I dont know how that works…