This is how far i got:
DarkOS(core)
local p = peripheral.wrap("left") function encryption(encr) key = p.generateSymmetricKey("AES") encodedKey = key.encode() ciphertext = key.encrypt("AES", encr) return encodedKey, ciphertext end function decription(encoded ,encrypted) key = p.decodeKey("AES", encoded) plaintext = key.decrypt("AES", encrypted) return plaintext end
The encryption of the card: (Would it be better to use asymmetrical encryption for this? can't seem to figure that out tho)
os.loadAPI("darkOS") encr = darkOS.encryption("user"..math.random(10,50)) local reader = peripheral.wrap("mag card reader_0") while true do local event, arg1, arg2, arg3 = os.pullEvent() reader.beginWrite(encr, "DarkEyeDragon") if event == "mag_write_done" then print("card made") end end
The decryption part is just a mess. I got no idea how to even start on this xD
os.loadAPI("darkOS") while true do local event,arg1,arg2,arg3 = os.pullEvent() decri = darkOS.decription(arg1) if arg1 == decri then print("yey") else print("nope") end end
Documentation:
http://www.computerc...0272#entry90272 (API of the Cryptographic Accelerator)
http://www.computerc...ss-peripherals/
(general information on the mod)
To conclude:
I'm trying to encrypt a string onto a Mag-stripe card to then later decrypt it back and decode it. To check weather or not the person is valid to enter the building.
Edit: Some might be interested in why i want to do this?
Its just to prevent people from making a mag-card reader and pulling the information from the card and make a "cracked" version of it to break into my building. I know it sounds highly unlikely that that will ever happen. But hey, one can never be too secure.
Edited by DarkEyeDragon, 23 June 2016 - 04:53 PM.