Jump to content

[HELP] En(De)cryption


nikitafloy

Recommended Posts

You could use teaEncode/teaDecode, but it would be better to come up with your own algorithm for this, because it would a heavy use for the client to have to encode/decode a txd of dff string every time, because they're rather large strings.

You should write something this to the dff and txd files:

fdsjak actualTxdDffContents dfkadsl 

and then use string.sub to get the actual contents of the file

Example functions:

function hideRealContents ( str ) 
    return "dfdaskf"..str.."fkjdsak"; 
end  
  
function getRealContents ( str ) 
    return string.sub ( str, 7, string.len ( str ) - 7 ); 
end 

Link to comment
  • 3 weeks later...
You could use teaEncode/teaDecode, but it would be better to come up with your own algorithm for this, because it would a heavy use for the client to have to encode/decode a txd of dff string every time, because they're rather large strings.

You should write something this to the dff and txd files:

fdsjak actualTxdDffContents dfkadsl 

and then use string.sub to get the actual contents of the file

Example functions:

function hideRealContents ( str ) 
    return "dfdaskf"..str.."fkjdsak"; 
end  
  
function getRealContents ( str ) 
    return string.sub ( str, 7, string.len ( str ) - 7 ); 
end 

Do u mean it?

  
function getRealContents ( str ) 
    return string.sub ( str, 7, string.len ( str ) - 7 ) 
end 
  
local str = "dfdask" .. "data/elegy.txd" .. "fkjdsak" 
local str1 = "dfdask" .. "data/elegy.dff" .. "fkjdsak" 
  
function replaceModel()                   
    txd = engineLoadTXD(getRealContents(str), 562 ) 
    engineImportTXD(txd, 562) 
    dff = engineLoadDFF(getRealContents(str1), 562 ) 
    engineReplaceModel(dff, 562) 
end 
addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()), replaceModel) 

Link to comment
You should create your own encryption system

if someone here give you an idea

everyone gonna now how did you encrypt them and they'll know how to decrypt them

You might be able to use xor to make it harder for noobs to mess with files.

Link to comment

I've made something

server

Files = { 
    -- id model, txd path, dff path 
    { 0, "test.txd", "test.dff" } 
}; 
  
Content = { }; 
  
addEventHandler ( "onResourceStart", resourceRoot, 
    function ( ) 
        for _, v in pairs ( Files ) do 
            local id, txd, dff = unpack ( v ); 
            Content [ id ] = { }; 
             
            -- getting content of TXD 
            local txdFile = File ( txd, true ); 
            if txdFile then 
                local content = txdFile:read ( txdFile:getSize ( ) ); 
                Content [ id ] [ "txd" ] = content; 
            end 
             
            -- getting content of DFF 
            local dffFile = File ( dff, true ); 
            if dffFile then 
                local content = dffFile:read ( dffFile:getSize ( ) ); 
                Content [ id ] [ "dff" ] = content; 
            end 
        end 
    end 
); 
  
addEvent ( "server:getContent", true ) 
addEventHandler ( "server:getContent", root, 
    function ( ) 
        triggerClientEvent ( source, "client:applyContent", source, Content ); 
    end 
); 

client

addEventHandler ( "onClientResourceStart", resourceRoot, 
    function ( ) 
        triggerServerEvent ( "server:getContent", localPlayer ); 
    end 
); 
  
addEvent ( "client:applyContent", true ); 
addEventHandler ( "client:applyContent", root, 
    function ( Content ) 
        for model, c in pairs ( Content ) do 
            local txd, dff = c["txd"], c["dff"]; 
             
            local loadedTXD = EngineTXD ( txd ); 
            local loadedDFF = EngineDFF ( dff ); 
            if loadedTXD and loadedDFF then 
                loadedTXD:import ( model ); 
                loadedDFF:replace ( model ); 
            end 
        end 
    end 
); 

I really don't know if it will work, but you can try. To make it work you have to turn on OOP in meta.

Edited by Guest
Link to comment
  • 2 months later...
I've made something

server

Files = { 
    -- id model, txd path, dff path 
    { 0, "test.txd", "test.dff" } 
}; 
  
Content = { }; 
  
addEventHandler ( "onResourceStart", resourceRoot, 
    function ( ) 
        for _, v in pairs ( Files ) do 
            local id, txd, dff = unpack ( v ); 
            Content [ id ] = { }; 
             
            -- getting content of TXD 
            local txdFile = File ( txd, true ); 
            if txdFile then 
                local content = txdFile:read ( txdFile:getSize ( ) ); 
                Content [ id ] [ "txd" ] = content; 
            end 
             
            -- getting content of DFF 
            local dffFile = File ( dff, true ); 
            if dffFile then 
                local content = dffFile:read ( dffFile:getSize ( ) ); 
                Content [ id ] [ "dff" ] = content; 
            end 
        end 
    end 
); 
  
addEvent ( "server:getContent", true ) 
addEventHandler ( "server:getContent", root, 
    function ( ) 
        triggerClientEvent ( source, "client:applyContent", source, Content ); 
    end 
); 

client

addEventHandler ( "onClientResourceStart", resourceRoot, 
    function ( ) 
        triggerServerEvent ( "server:getContent", localPlayer ); 
    end 
); 
  
addEvent ( "client:applyContent", true ); 
addEventHandler ( "client:applyContent", root, 
    function ( Content ) 
        for model, c in pairs ( Content ) do 
            local txd, dff = c["txd"], c["dff"]; 
             
            local loadedTXD = EngineTXD ( txd ); 
            local loadedDFF = EngineDFF ( dff ); 
            if loadedTXD and loadedDFF then 
                loadedTXD:import ( model ); 
                loadedDFF:replace ( model ); 
            end 
        end 
    end 
); 

I really don't know if it will work, but you can try. To make it work you have to turn on OOP in meta.

Dont work. :roll:

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