Jump to content

How to use TeaEncode?


CoreyHUN

Recommended Posts

thefile = fileOpen( < File > ) 
content = fileRead(thefile) 
encodedContent = teaEncode(content, < Key >) 

But I don't see why you would do that - sooner or later you will need to decode the file, save it, load it through engineLoadDFF and then maybe delete the decoded one. MTA currently doesn't support loading DFF files into buffer to create a 'DFF' element out of it.

If you want to encode it into a standard base64 (without tiny encryption algorithm), then use base64Encode and base64Decode, but as said earlier, it's quite useless for DFF files.

Link to comment
local info = "http://er-mta.net" 
local key = "somewordshere" 
local encrypted = teaEncode(info,key) 
outputChatBox(encrypted) -- will output hashed line, in this example: QfHxIWo2bp2J4rUr4rnPcboBG84R0KJ0 
local decrypted = teaDecode(encrypted,key) -- decrypt with the same key 
outputChatBox(decrypted) -- will output "http://er-mta.net" 

That's the basic example. Encrypt it and then fileWrite. You can decrypt your file and use engineLoadDFF(decrypted) with that string you got. This way, you better use:

function teaEncodeBinary( data, key ) 
    return teaEncode( base64encode( data ), key ) 
end 
function teaDecodeBinary( data, key ) 
    return base64decode( teaDecode( data, key ) ) 
end 

But I don't see why you would do that - sooner or later you will need to decode the file, save it, load it through engineLoadDFF and then maybe delete the decoded one. MTA currently doesn't support loading DFF files into buffer to create a 'DFF' element out of it.

Not really. It supports raw data since 1.4.1 r7088

screenshot_at_22_25_00.png

Link to comment

Well.. You can do onClientResourceStart resourceRoot triggerServerEvent requestDFFs

and the make the server read the file stored in the resource folder (not added to meta.xml, so that it won't be downloaded by the client), send it to the client (probably encoded, so that hackers cannot "pull" data from networking), decode it in the client, and load it into DFF form by raw data.

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...