Jump to content

Protecting files


dima3367

Recommended Posts

Hello everyone! Me again.
For your server doing exceptionally unique models of machines and facilities, but there are "good" people who brazenly steal them from the server is removed from the cache.
Previously, I used protection when a DFF and TXD file encoded in any way LUAC and they can not be opened. Since a lot of models and objects (approximately 1300 MB), the server load became wildly and many players disappearing textures and were hovering.

I know that there is a fairly simple way in which you can not open the file TXD.
Tell me, how is it possible to do.
I hope you understand what I mean.


Thanks in advance and sorry for my bad english.

Edited by dima3367
Link to comment

Well you would get the contents of the .dff using fileRead and then pass that to teaEncode, teaEncode has 2 arguments, that is data to encrypt and a key. You choose whatever key you want, it's like a password. Then on the client you use the same key to decrypt the data.

Do you understand? Im on a phone atm so i cant really write actual code.

Link to comment

I don't know what you're saying but it would look something like this:

Server:

local file = fileOpen("file.dff") --Open the file you want
local data = fileRead(file, fileGetSize(file)) --Get the data in it
fileClose(file) --Don't need it anymore
data = teaEncode(data, "secret") --Encrypt the data with the passkey "secret"

if fileExists("protected/file.dff") then --Check if it's there already
  fileDelete("protected/file.dff") --If so, delete it
end
local newFile = fileCreate("protected/file.dff") --Create a new one in 'protected' directory (so the names don't collide)
fileWrite(newFile, data) --Write the encrypted data
fileClose(newFile) --Save & close

You would have to restart the resource after the encryption so that the HTTP cache is updated and players download the new ecrypted versions.

Client:

local file = fileOpen("protected/file.dff") --open the encrypted file
local data = fileRead(file, fileGetSize(file)) --Read the encrypted data
fileClose(file)
data = teaDecode(data, "secret") --Decrypt the data using the "secret" passkey

local dff = engineLoadDFF(data) --Load the DFF data
--Do your stuff here..

Now in meta:

<meta>
	<!-- Your scripts and stuff -->
  	<file src="protected/file.dff">
</meta>

Don't put in the original files.

 

And of course, if it's not just a single file then rework it into a loop, this is just an example.

Edited by MIKI785
  • Like 2
Link to comment

It is perfectly. But you're mine I do not fully understand. I have models of cars are replaced. That is their DFF and TCD go to cash to the player. I need to make sure that they were in the cache, but as it were coded, what would they had not been able to edit programs.

Here's how to replace a model

Client: 

function replaceModel()
txd = engineLoadTXD('file.txd',420)
engineImportTXD(txd,420)
dff = engineLoadDFF('file.dff',420)
engineReplaceModel(dff,420)
end
addEventHandler ( 'onClientResourceStart', getResourceRootElement(getThisResource()), replaceModel)

 

Link to comment

There's no need to use that resource, just use TEA, it will do the job. I think i've answered your question, that is how to protect files. You should try and experiment around yourself with what i gave you, if you expect me to post a full code here that you'll just copy and paste then you're wrong and you'll never learn.

  • Like 1
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...