Resource:Compiler: Difference between revisions
No edit summary |
|||
(4 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{Resource page}} | {{Resource page}} | ||
<div style="padding:10px; border-radius:2px;font-size:14px;"> | |||
'''Name''': Compiler | |||
'''Developer''': [[User:GalAnonim]] (Rick) | |||
'''State''': <span style="color:#55FF55;text-shadow:black 0em 0em 0.3em;">OpenSource</span> | |||
'''GitHub Source''': https://github.com/httpRick/Compiler/tree/master | |||
'''Server Discord''': https://discord.gg/gJszaFjDQA | |||
'''Current Version''': 1.0.0 | |||
</div> | |||
== Overview == | == Overview == | ||
Line 71: | Line 84: | ||
<section name="Server" class="server" show="true"> | <section name="Server" class="server" show="true"> | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function onResourceStart() | |||
local encryptedData = exports.Compiler:fileCompile("yourFile.txt", "YourPassword") | local encryptedData = exports.Compiler:fileCompile("yourFile.txt", "YourPassword") | ||
if encryptedData then | if encryptedData then | ||
Line 82: | Line 95: | ||
outputChatBox("Failed to encrypted yourFile.txt") | outputChatBox("Failed to encrypted yourFile.txt") | ||
end | end | ||
end) | end | ||
addEventHandler( "onResourceStart", resourceRoot, onResourceStart) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | </section> | ||
Line 88: | Line 103: | ||
<section name="Client" class="client" show="true"> | <section name="Client" class="client" show="true"> | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function onClientResourceStart() | |||
local txd = exports.Compiler:fileCompile("banshee.txd", "YourPassword") | local txd = exports.Compiler:fileCompile("banshee.txd", "YourPassword") | ||
local dff = exports.Compiler:fileCompile("banshee.dff", "YourPassword") | local dff = exports.Compiler:fileCompile("banshee.dff", "YourPassword") | ||
Line 103: | Line 118: | ||
outputChatBox("Failed to encrypted model banshee") | outputChatBox("Failed to encrypted model banshee") | ||
end | end | ||
end) | end | ||
addEventHandler( "onClientResourceStart", resourceRoot, onClientResourceStart) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | </section> | ||
Line 110: | Line 126: | ||
<section name="Server" class="server" show="true"> | <section name="Server" class="server" show="true"> | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function onResourceStart() | |||
local decryptedData = exports.Compiler:fileDecompile("yourFile.txtc", "YourPassword") | local decryptedData = exports.Compiler:fileDecompile("yourFile.txtc", "YourPassword") | ||
if decryptedData then | if decryptedData then | ||
Line 118: | Line 134: | ||
outputChatBox("Failed to decrypted yourFile.txtc") | outputChatBox("Failed to decrypted yourFile.txtc") | ||
end | end | ||
end) | end | ||
addEventHandler( "onResourceStart", resourceRoot, onResourceStart) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | </section> | ||
Line 124: | Line 141: | ||
<section name="Client" class="client" show="true"> | <section name="Client" class="client" show="true"> | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function onClientResourceStart() | |||
local txd = exports.Compiler:fileDecompile("banshee.txdc", "YourPassword") | local txd = exports.Compiler:fileDecompile("banshee.txdc", "YourPassword") | ||
local dff = exports.Compiler:fileDecompile("banshee.dffc", "YourPassword") | local dff = exports.Compiler:fileDecompile("banshee.dffc", "YourPassword") | ||
Line 136: | Line 153: | ||
outputChatBox("Failed to decrypted model banshee") | outputChatBox("Failed to decrypted model banshee") | ||
end | end | ||
end) | end | ||
addEventHandler( "onClientResourceStart", resourceRoot, onClientResourceStart) | |||
</syntaxhighlight> | |||
</section> | |||
===replaceCompileFile=== | |||
<section name="Server" class="server" show="true"> | |||
<syntaxhighlight lang="lua"> | |||
function onResourceStart() | |||
local isEncrypted = exports.Compiler:replaceCompileFile("yourFile.txt", "YourPassword", "yourFile.txtc") | |||
if isEncrypted then | |||
outputChatBox("Successfully encrypted and created yourFile.txtc") | |||
else | |||
outputChatBox("Failed to encrypted yourFile.txt") | |||
end | |||
end | |||
addEventHandler( "onResourceStart", resourceRoot, onResourceStart) | |||
</syntaxhighlight> | |||
</section> | |||
<section name="Client" class="client" show="true"> | |||
<syntaxhighlight lang="lua"> | |||
function onClientResourceStart() | |||
local isEncryptedTxd = exports.Compiler:replaceCompileFile("banshee.txd", "YourPassword") | |||
local isEncryptedDff = exports.Compiler:replaceCompileFile("banshee.dff", "YourPassword") | |||
if isEncryptedTxd and isEncryptedDff then | |||
outputChatBox("Successfully encrypted and overwritten banshee model files") | |||
else | |||
outputChatBox("Failed to encrypted model banshee") | |||
end | |||
end | |||
addEventHandler( "onClientResourceStart", resourceRoot, onClientResourceStart) | |||
</syntaxhighlight> | |||
</section> | |||
===replaceDecompileFile=== | |||
<section name="Server" class="server" show="true"> | |||
<syntaxhighlight lang="lua"> | |||
function onResourceStart() | |||
local isDecrypted = exports.Compiler:replaceDecompileFile("yourFile.txtc", "YourPassword", "yourFile.decrypted") | |||
if isEncrypted then | |||
outputChatBox("Successfully decrypted and created yourFile.decrypted") | |||
else | |||
outputChatBox("Failed to decrypted yourFile.txtc") | |||
end | |||
end | |||
addEventHandler( "onResourceStart", resourceRoot, onResourceStart) | |||
</syntaxhighlight> | |||
</section> | |||
<section name="Client" class="client" show="true"> | |||
<syntaxhighlight lang="lua"> | |||
function onClientResourceStart() | |||
local isDecryptedTxd = exports.Compiler:replaceDecompileFile("banshee.txd", "YourPassword") | |||
local isDecryptedDff = exports.Compiler:replaceDecompileFile("banshee.dff", "YourPassword") | |||
if isDecryptedTxd and isDecryptedDff then | |||
outputChatBox("Successfully decrypted and overwritten banshee model files") | |||
else | |||
outputChatBox("Failed to decrypted model banshee") | |||
end | |||
end | |||
addEventHandler( "onClientResourceStart", resourceRoot, onClientResourceStart) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | </section> |
Latest revision as of 13:54, 1 November 2021
Name: Compiler
Developer: User:GalAnonim (Rick)
State: OpenSource
GitHub Source: https://github.com/httpRick/Compiler/tree/master
Server Discord: https://discord.gg/gJszaFjDQA
Current Version: 1.0.0
Overview
A simple-to-use resource that can be exported both on the client side and on the server side. consisting in the encryption/decryption of files
Exported functions
fileCompile
This function encrypts the data of the file
string exports.Compiler:fileCompile(string filePath, var key, [int maxBytes = 1024])
Required Arguments
- string filePath: The filepath of the file in the following format: ":resourceName/path". 'resourceName' is the name of the resource the file is in, and 'path' is the path from the root directory of the resource to the file.
- For example, if there is a file named 'coolObjects.txt' in the resource 'objectSearch', it can be opened from another resource this way: fileOpen(":objectSearch/coolObjects.txt").
- If the file is in the current resource, only the file path is necessary, e.g. fileOpen("coolObjects.txt").
- var key: The key you want to use as the file encoding key (the first 16 characters of the result are used)
Optional Arguments
- int maxBytes: Maximum interger of bytes to be encoded, default is 1024 bytes. (using less than 1024 bytes is not recommended)
Returns
Returns the encrypted bytes that have been read in the file, if something is unsuccessful, returns false.
fileDecompile
This function decrypted the data of the file
string exports.Compiler:fileDecompile(string filePath, var key)
Required Arguments
- string filePath: The filepath of the file in the following format: ":resourceName/path". 'resourceName' is the name of the resource the file is in, and 'path' is the path from the root directory of the resource to the file.
- For example, if there is a file named 'coolObjects.txt' in the resource 'objectSearch', it can be opened from another resource this way: fileOpen(":objectSearch/coolObjects.txt").
- If the file is in the current resource, only the file path is necessary, e.g. fileOpen("coolObjects.txt").
- var key: The key you want to use as the file decrypted key (the first 16 characters of the result are used)
Returns
Returns the decrypted bytes that have been read in the file, if something is unsuccessful, returns false.
replaceCompileFile
The function encrypts and overwrites the file or creates a new one at the specified path
boolean exports.Compiler:replaceCompileFile(string filePath, var key, [string newFilePath, int maxBytes])
Required Arguments
- string filePath: The filepath of the file in the following format: ":resourceName/path". 'resourceName' is the name of the resource the file is in, and 'path' is the path from the root directory of the resource to the file.
- For example, if there is a file named 'coolObjects.txt' in the resource 'objectSearch', it can be opened from another resource this way: fileOpen(":objectSearch/coolObjects.txt").
- If the file is in the current resource, only the file path is necessary, e.g. fileOpen("coolObjects.txt").
- var key: The key you want to use as the file decrypted key (the first 16 characters of the result are used)
Optional Arguments
- string newFilePath: Destination filepath for the specified source file in the same format.
- int maxBytes: Maximum interger of bytes to be encoded, default is 1024 bytes. (using less than 1024 bytes is not recommended)
Returns
Returns true on valid encryption, and returns false if unsuccessful
replaceDecompileFile
The function decrypted and overwrites the file or creates a new one at the specified path
boolean exports.Compiler:replaceDecompileFile(string filePath, var key, [string newFilePath])
Required Arguments
- string filePath: The filepath of the file in the following format: ":resourceName/path". 'resourceName' is the name of the resource the file is in, and 'path' is the path from the root directory of the resource to the file.
- For example, if there is a file named 'coolObjects.txt' in the resource 'objectSearch', it can be opened from another resource this way: fileOpen(":objectSearch/coolObjects.txt").
- If the file is in the current resource, only the file path is necessary, e.g. fileOpen("coolObjects.txt").
- var key: The key you want to use as the file decrypted key (the first 16 characters of the result are used)
Optional Arguments
- string newFilePath: Destination filepath for the specified source file in the same format.
Returns
Returns true on valid decryption, and returns false if unsuccessful
Examples
fileCompile
function onResourceStart() local encryptedData = exports.Compiler:fileCompile("yourFile.txt", "YourPassword") if encryptedData then local fileHandler = fileCreate("yourFile.txtc") fileWrite(fileHandler, encryptedData) fileClose(fileHandler) outputChatBox(encryptedData) outputChatBox("Successfully encrypted yourFile.txt") else outputChatBox("Failed to encrypted yourFile.txt") end end addEventHandler( "onResourceStart", resourceRoot, onResourceStart)
function onClientResourceStart() local txd = exports.Compiler:fileCompile("banshee.txd", "YourPassword") local dff = exports.Compiler:fileCompile("banshee.dff", "YourPassword") if txd and dff then local fileHandlerTxd = fileCreate("banshee.txdc") fileWrite(fileHandlerTxd, txd) fileClose(fileHandlerTxd) local fileHandlerDff = fileCreate("banshee.dffc") fileWrite(fileHandlerDff, dff) fileClose(fileHandlerDff) outputChatBox("Successfully encrypted model banshee") else outputChatBox("Failed to encrypted model banshee") end end addEventHandler( "onClientResourceStart", resourceRoot, onClientResourceStart)
fileDecompile
function onResourceStart() local decryptedData = exports.Compiler:fileDecompile("yourFile.txtc", "YourPassword") if decryptedData then outputChatBox(decryptedData) outputChatBox("Successfully decrypted yourFile.txtc") else outputChatBox("Failed to decrypted yourFile.txtc") end end addEventHandler( "onResourceStart", resourceRoot, onResourceStart)
function onClientResourceStart() local txd = exports.Compiler:fileDecompile("banshee.txdc", "YourPassword") local dff = exports.Compiler:fileDecompile("banshee.dffc", "YourPassword") if txd and dff then local loadTXD = engineLoadTXD(txd) engineImportTXD(loadTXD, 429) local loadDFF = engineLoadDFF(dff) engineReplaceModel(loadDFF, 429) outputChatBox("Successfully decrypted model banshee and loaded") else outputChatBox("Failed to decrypted model banshee") end end addEventHandler( "onClientResourceStart", resourceRoot, onClientResourceStart)
replaceCompileFile
function onResourceStart() local isEncrypted = exports.Compiler:replaceCompileFile("yourFile.txt", "YourPassword", "yourFile.txtc") if isEncrypted then outputChatBox("Successfully encrypted and created yourFile.txtc") else outputChatBox("Failed to encrypted yourFile.txt") end end addEventHandler( "onResourceStart", resourceRoot, onResourceStart)
function onClientResourceStart() local isEncryptedTxd = exports.Compiler:replaceCompileFile("banshee.txd", "YourPassword") local isEncryptedDff = exports.Compiler:replaceCompileFile("banshee.dff", "YourPassword") if isEncryptedTxd and isEncryptedDff then outputChatBox("Successfully encrypted and overwritten banshee model files") else outputChatBox("Failed to encrypted model banshee") end end addEventHandler( "onClientResourceStart", resourceRoot, onClientResourceStart)
replaceDecompileFile
function onResourceStart() local isDecrypted = exports.Compiler:replaceDecompileFile("yourFile.txtc", "YourPassword", "yourFile.decrypted") if isEncrypted then outputChatBox("Successfully decrypted and created yourFile.decrypted") else outputChatBox("Failed to decrypted yourFile.txtc") end end addEventHandler( "onResourceStart", resourceRoot, onResourceStart)
function onClientResourceStart() local isDecryptedTxd = exports.Compiler:replaceDecompileFile("banshee.txd", "YourPassword") local isDecryptedDff = exports.Compiler:replaceDecompileFile("banshee.dff", "YourPassword") if isDecryptedTxd and isDecryptedDff then outputChatBox("Successfully decrypted and overwritten banshee model files") else outputChatBox("Failed to decrypted model banshee") end end addEventHandler( "onClientResourceStart", resourceRoot, onClientResourceStart)