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

Script Encryption

Started by cheetah, 25 July 2013 - 12:23 AM
cheetah #1
Posted 25 July 2013 - 02:23 AM
Hello4everybody,

How can i encrypt my program's source code to prevent simple code view?

I don't need really strong encryption - just protect it from code viewing and modification.

P.S. Can i somehow use bytecode instead? Ex. compile script somehow?
GopherAtl #2
Posted 25 July 2013 - 03:23 AM
I happen to have made something for this a loong time ago, just to see if I could. I've never actually used it to release any "obfuscated" lua programs, but just found and tested it, and it seems to work.

program:
pastebin get AucFCRxS lua2bin

download as lua2bin, and use like this:

> lua2bin myProgram myProgram2
It will take myProgram, which is lua code, compile it to bytecode, dump that to a string, encode that string in base64, and then write a new lua program that contains that base64 string and, when run, loads, decodes, and runs the original program. The resulting output is a valid program that can safely be sent over rednet or http, and so distributed on pastebin, etc.

Thought I'd share this since I made it and have never used it for anything, and it's exactly what you're asking for, but… I'm not sure I'd recommend actually using it to distribute your programs. it is fantastically unlikely anyone wants to steal your code, and if they really did, this wouldn't actually stop them, just make it harder. It will also cause the program to generate very cryptic error messages if anything goes wrong, making it harder for you to find and fix bugs reported by other people. If you want to do it anyway… go for it!
cheetah #3
Posted 25 July 2013 - 04:02 AM
I happen to have made something for this a loong time ago, just to see if I could. I've never actually used it to release any "obfuscated" lua programs, but just found and tested it, and it seems to work.

program:
pastebin get AucFCRxS lua2bin

download as lua2bin, and use like this:

> lua2bin myProgram myProgram2
It will take myProgram, which is lua code, compile it to bytecode, dump that to a string, encode that string in base64, and then write a new lua program that contains that base64 string and, when run, loads, decodes, and runs the original program. The resulting output is a valid program that can safely be sent over rednet or http, and so distributed on pastebin, etc.

Thought I'd share this since I made it and have never used it for anything, and it's exactly what you're asking for, but… I'm not sure I'd recommend actually using it to distribute your programs. it is fantastically unlikely anyone wants to steal your code, and if they really did, this wouldn't actually stop them, just make it harder. It will also cause the program to generate very cryptic error messages if anything goes wrong, making it harder for you to find and fix bugs reported by other people. If you want to do it anyway… go for it!

Thanks, that's what i need. I need only to encrypt my auth utility, because otherwise anybody can find a way to bypass it, studying the code.
Lyqyd #4
Posted 25 July 2013 - 02:12 PM
Please note that obfuscated programs may not be posted to the ComputerCraft forums.
GopherAtl #5
Posted 25 July 2013 - 05:27 PM
ah, right, I'd forgotten about that rule, should've mentioned it.
Zudo #6
Posted 26 July 2013 - 04:57 PM
Please note that obfuscated programs may not be posted to the ComputerCraft forums.

:(/> I wish I could keep some of my code private.
Lyqyd #7
Posted 26 July 2013 - 06:12 PM
We can't verify that code isn't malicious if we can't read the source. We generally consider it a higher priority to be able to prevent malicious code remaining on the forums than to allow people to keep their bad "encryption" programs "secret", or whatever else they want to post obfuscated code for.
Thib0704 #8
Posted 26 July 2013 - 08:23 PM
I guess also For other people to learn from the community's program ?
tell me if Im wrong Liquid ?