Jump to content




AES Encryption


  • You cannot reply to this topic
68 replies to this topic

#21 SquidDev

    Frickin' laser beams | Resident Necromancer

  • Members
  • 1,427 posts
  • LocationDoes anyone put something serious here?

Posted 30 June 2014 - 10:40 AM

 theoriginalbit, on 30 June 2014 - 12:52 AM, said:

if you've manually typed that string based off what the terminal has shown, then you've typed it wrong, any non-displaying character in ComputerCraft is drawn with a '?'

That never actually occurred to me. You can always escape the string (local AESCode = string.format("%q", enc) - from memory so I might be wrong) if you need to store it in the code.

#22 lebalusch

  • Members
  • 49 posts

Posted 30 June 2014 - 03:26 PM

All i have been trying to do is Encrypt a string. From there save the cipher message in a file. then at a later date take the cipher text and decrypt. Yes i was printing to screen as a quick and easy way of getting to the cipher text.

#23 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 01 July 2014 - 01:01 AM

well you definitely cannot do that, the cypher text will contain characters that cannot display, so putting the '?' that you see into your program will not be the same as what it may have been trying to print, for example '\245'

#24 lebalusch

  • Members
  • 49 posts

Posted 01 July 2014 - 03:55 PM

Would printing to and loading from a file be the same? Or is it just the ComputerCraft monitor or terminal cant display all the characters?

#25 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 01 July 2014 - 04:02 PM

no definitely not, writing to a file and then using that would function correctly, it is only the terminal that cannot display the characters, and for good reason too, how do you display a character that doesn't have a graphical representation? well most systems do a ☐ or a ¿ in ComputerCraft's case dan decided to have it render just a normal ?

#26 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 01 July 2014 - 04:34 PM

Writing to and reading from files will work correctly in binary mode, but not in textual mode.

#27 lebalusch

  • Members
  • 49 posts

Posted 01 July 2014 - 05:05 PM

Thank you guys this has help explain it a lot.

So if i am getting this right you would take a file you want to encrypt. convert it all to a string. Encrypt it then convert to binary and save to file. When it comes to Decrypting you load file into a string, convert back to textual from binary then Decrypt. Leaving you with a readable file again.

This seems a lot of work to do and loads of coding.

#28 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 01 July 2014 - 05:32 PM

using this API definitely not lots of coding. however if you plan on using this for the server/client architecture you discussed in the PM with me, then sadly you'll quickly find a LuaJ bug with strings that will bring this idea to a grinding halt.

Edited by theoriginalbit, 01 July 2014 - 05:32 PM.


#29 lebalusch

  • Members
  • 49 posts

Posted 01 July 2014 - 06:17 PM

 theoriginalbit, on 01 July 2014 - 05:32 PM, said:

using this API definitely not lots of coding. however if you plan on using this for the server/client architecture you discussed in the PM with me, then sadly you'll quickly find a LuaJ bug with strings that will bring this idea to a grinding halt.

Thank you for the heads up on that. No i think im just going to make a Network wide loging on program with the passwords SHA256'ed. I was looking at the AES as i was also thinking about files being sent over the network. Luckily I only play with friends on a server so encryption isn't a NEED but if i was to be building programs that i might want to release one day i might as well have a look at how its all done and implement early.

#30 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 01 July 2014 - 11:20 PM

yeah okay so you'll still have the problem unfortunately; sadly if a string comes in contact with the event system is where it gets problematic, any value >127 just becomes 127, it's very annoying. anyway to mitigate against it just use a base64 script; encrypt, convert to base64, send, convert to base10, decrypt.

#31 Anavrins

  • Members
  • 775 posts

Posted 02 July 2014 - 06:51 AM

Or you could use tables to store all the bytes of a string and then send the seriallized table over rednet...
Spoiler

Edited by Anavrins, 02 July 2014 - 06:54 AM.


#32 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 02 July 2014 - 06:56 AM

 Anavrins, on 02 July 2014 - 06:51 AM, said:

Or you could use tables to store all the bytes of a string...
Spoiler
that wouldn't fix anything. the LuaJ bug would still exist on the chars as they're passing through the event system.

#33 lebalusch

  • Members
  • 49 posts

Posted 02 July 2014 - 03:29 PM

I'm starting to think a one time key is a far simpler way to go. Anavrins idea of break it into bits, send it then recompile into a string kind of makes sense but you are then left with a far to big string to encrypt/ decrypt.

But lets consider that for one sec could you not break it into chunks encrypt them all individually and then send. at the other end decrypt all the chunks then stick them all back together? Rather than treating it as a document you treat it as a load of sentences?

do you also have a link so i can read about this lua j bug please. This is clearly why i cant find a all in one package to sending and receiving files while encrypting on route.

#34 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 03 July 2014 - 02:35 AM

 lebalusch, on 02 July 2014 - 03:29 PM, said:

do you also have a link so i can read about this lua j bug please.
I could only find two, there were another two around somewhere that dove slightly deeper into it, but I couldn't find them again. Link 1 Link 2

Edited by theoriginalbit, 03 July 2014 - 02:35 AM.


#35 Goof

  • Members
  • 751 posts

Posted 26 August 2014 - 03:49 PM

Bump;

I just tried this with a 216 long string, however it just shutdown the computer.
Is it possible to make it Yield every so often,
The compressed version is quite hard to read, so if possible, how / where do i add it?


Thanks in Advance

Edited by Mikk809h, 26 August 2014 - 03:49 PM.


#36 jaredallard

  • Members
  • 124 posts
  • LocationSeattle, WA

Posted 26 November 2014 - 06:00 PM

Just submitted a pull request too the github, which has it use a different bit library, which also dramatically increases performance.

#37 Rougeminner

  • Members
  • 151 posts

Posted 29 November 2014 - 05:59 AM

i am having trouble with decrypting a rednet message. i thought that maybe if i encrypted the message before i sent it an provided the receiver the proper key it would be able to decrypt arg2 back into humanly readable characters that make sense. where was i wrong with this

Edited by Rougeminner, 29 November 2014 - 06:31 AM.


#38 1lann

  • Members
  • 516 posts
  • LocationSeattle

Posted 29 November 2014 - 06:40 AM

 Rougeminner, on 29 November 2014 - 05:59 AM, said:

i am having trouble with decrypting a rednet message. i thought that maybe if i encrypted the message before i sent it an provided the receiver the proper key it would be able to decrypt arg2 back into humanly readable characters that make sense. where was i wrong with this
You may need to use a base64 encoder so all of the data is ASCII safe. Here's one from KillaVanilla: http://pastebin.com/pp3kpb19
Make sure you encode before sending through rednet, then decode on receiving.

#39 Rougeminner

  • Members
  • 151 posts

Posted 29 November 2014 - 06:57 PM

if i provide the code can you tell me what i am doing wrong after i implemented base64. right now i have transmit code input2 = Base64.encode(input2) input2 = AES.encrypt("XXXX",input2) redness.broadcast(input2,channel) and receive code is if event == "rednet_message" then arg2 = AES.decrypt(arg2) print(arg1,',',arg2) i get a java election thrown error. is it because i am encoding a string

#40 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 29 November 2014 - 07:23 PM

 Rougeminner, on 29 November 2014 - 06:57 PM, said:

i get a java election thrown error. is it because i am encoding a string

This is meant to encode strings, so no

 Rougeminner, on 29 November 2014 - 06:57 PM, said:

if i provide the code can you tell me what i am doing wrong after i implemented base64

Yes

 Rougeminner, on 29 November 2014 - 06:57 PM, said:

right now i have transmit code

input2 = Base64.encode(input2)
input2 = AES.encrypt("XXXX",input2)
redness.broadcast(input2,channel)

and receive code is

if event == "rednet_message" then
arg2 = AES.decrypt(arg2)
print(arg1,',',arg2)

Well, considering you never decrypted from base64, that would never work. Also, since you encrypted in base64 before encrypting with AES, it won't protect against event corruption.

input2 = base64.encode( AES.encrypt( "XXX", input2 ) )
rednet.broadcast( input2 )

if event == "rednet_message" then
  arg2 = AES.decrypt( base64.decrypte( arg2 ) ) 
  print(arg1,',',arg2)






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users