116 posts
Location
At my Computer coding for the Computer in my Computer
Posted 31 August 2012 - 06:50 PM
Hi, I'm just wondering if there is a way that i can encrypt a program possibly with a null key so I am the only one who can access it?
I want to have a program of mine to be un-readable by a user unless they decrypt it (out of game or in-game are both fine), but still be able to be run from a computer. I run my own server and I want some programs to be forced upon the user and un-editable, I already have got some help with some code to put and keep the program on a given computer.
Thanks for the help!
436 posts
Posted 31 August 2012 - 07:13 PM
I don't think so. At least, not in this version. I think MysticT was working on something that would do that, and he might have put it into MysticOS, but I don't know. I haven't used it yet.
116 posts
Location
At my Computer coding for the Computer in my Computer
Posted 31 August 2012 - 07:20 PM
Not really. At least, not in this version. I think MysticT was working on something that would do that, and he might have put it into MysticOS, but I don't know. I haven't used it yet.
ok thanks, if anyone else has a idea i would appreciate the input
463 posts
Location
Germany
Posted 31 August 2012 - 07:56 PM
Im not sure if you can use it for whole programs, but you can convert an file into a function with loadfile(file) and then use string.dump(function) to compile a function in binary code. Then you could write it to an file.
CODE:
args={...}
function printUsage()
print("Usage: compile <program> <compiledprogram>")
end
if #args<1 or #args>2 then
printUsage()
return
end
p1=args[1]
p2=args[2]
if not fs.exists(p1) or fs.isDir(p1) then
print("File doesn't exist or is a dir")
return
end
if fs.exists(p2) then
print("File exists.")
return
end
local r=fs.open(p1, "r")
body=r.read()
r.close()
r=nil
local w=fs.open(p2, "w")
local str=string.dump(body) --compiles the string
local w.write(str)
w.close()
This should work: 1st arg=Program to compile, 2nd arg=Output File
And you should can run this like an normal program…
An other way is to download the StrUtils API from tomass1997 and encrypt the file with a key, and then you can decrypt the file on an other PC using the decrypt function of the StrUtils API.
116 posts
Location
At my Computer coding for the Computer in my Computer
Posted 01 September 2012 - 06:29 PM
Im not sure if you can use it for whole programs, but you can convert an file into a function with loadfile(file) and then use string.dump(function) to compile a function in binary code. Then you could write it to an file.
CODE:
args={...}
function printUsage()
print("Usage: compile <program> <compiledprogram>")
end
if #args<1 or #args>2 then
printUsage()
return
end
p1=args[1]
p2=args[2]
if not fs.exists(p1) or fs.isDir(p1) then
print("File doesn't exist or is a dir")
return
end
if fs.exists(p2) then
print("File exists.")
return
end
local r=fs.open(p1, "r")
body=r.read()
r.close()
r=nil
local w=fs.open(p2, "w")
local str=string.dump(body) --compiles the string
local w.write(str)
w.close()
This should work: 1st arg=Program to compile, 2nd arg=Output File
And you should can run this like an normal program…
An other way is to download the StrUtils API from tomass1997 and encrypt the file with a key, and then you can decrypt the file on an other PC using the decrypt function of the StrUtils API.
I just have one question, if I use this API would it have to be on a server or just my client?
116 posts
Location
At my Computer coding for the Computer in my Computer
Posted 01 September 2012 - 09:40 PM
is anyone going to answer?
1604 posts
Posted 01 September 2012 - 10:36 PM
I just have one question, if I use this API would it have to be on a server or just my client?
You just need to run it once to "compile" the program, and then use it like a normal program. So you just need to put it in a computer to compile the program and then distribute the compiled file.
116 posts
Location
At my Computer coding for the Computer in my Computer
Posted 01 September 2012 - 10:39 PM
I just have one question, if I use this API would it have to be on a server or just my client?
You just need to run it once to "compile" the program, and then use it like a normal program. So you just need to put it in a computer to compile the program and then distribute the compiled file.
I was talking about the StrUtils API that he mentioned, I just need to know if it needs to be on the server and the client or just the client.
1604 posts
Posted 01 September 2012 - 10:52 PM
Oh, sorry didn't get that :)/>/>
Well, you would need to have it when encrypting and decrypting it, so it has to be in both. But you can't run the program while encrypted, you need to decrypt it to a new file and then run it.
116 posts
Location
At my Computer coding for the Computer in my Computer
Posted 01 September 2012 - 11:05 PM
Oh, sorry didn't get that :)/>/>
Well, you would need to have it when encrypting and decrypting it, so it has to be in both. But you can't run the program while encrypted, you need to decrypt it to a new file and then run it.
Ok… so only the two people who are encrypting and decrypting need the api?
Also is there any way at all to make a program un-readable but sill run-able?
1604 posts
Posted 01 September 2012 - 11:09 PM
You can compile it like ardera said. But it can't be decompiled, so you need to keep a copy of the source if you want to modify it.
116 posts
Location
At my Computer coding for the Computer in my Computer
Posted 02 September 2012 - 02:45 AM
Ok, thanks for all you help!
116 posts
Location
At my Computer coding for the Computer in my Computer
Posted 02 September 2012 - 03:15 AM
Im not sure if you can use it for whole programs, but you can convert an file into a function with loadfile(file) and then use string.dump(function) to compile a function in binary code. Then you could write it to an file.
CODE:
args={...}
function printUsage()
print("Usage: compile <program> <compiledprogram>")
end
if #args<1 or #args>2 then
printUsage()
return
end
p1=args[1]
p2=args[2]
if not fs.exists(p1) or fs.isDir(p1) then
print("File doesn't exist or is a dir")
return
end
if fs.exists(p2) then
print("File exists.")
return
end
local r=fs.open(p1, "r")
body=r.read()
r.close()
r=nil
local w=fs.open(p2, "w")
local str=string.dump(body) --compiles the string
local w.write(str)
w.close()
This should work: 1st arg=Program to compile, 2nd arg=Output File
And you should can run this like an normal program…
An other way is to download the StrUtils API from tomass1997 and encrypt the file with a key, and then you can decrypt the file on an other PC using the decrypt function of the StrUtils API.
I ran your code and I got unexpected symbol on line 25…
Can I get some help?
1604 posts
Posted 02 September 2012 - 03:20 AM
Remove the local from that line. It should be:
w.write(str)
116 posts
Location
At my Computer coding for the Computer in my Computer
Posted 02 September 2012 - 03:25 AM
Thanks Mystic, now it works!
116 posts
Location
At my Computer coding for the Computer in my Computer
Posted 02 September 2012 - 03:37 AM
Ok, never mind it doesn't work, if I understand, the first arg is the file to compile, and the second is where to put it, either I don't know how to write where I want it to go or it really doesn't work, I get a attempt to call nil on line 20.