Skip to content

Commit 5a5f4a2

Browse files
Fix
1 parent 5734f2d commit 5a5f4a2

File tree

4 files changed

+33
-23
lines changed

4 files changed

+33
-23
lines changed

nando_crypt/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
files/*
2-
!files/empty.txt
2+
!files/.keep
33
nando_decrypter
44
nando_decrypter_keys.json
55
nando_encrypt.log

nando_crypt/c_encrypt.lua

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,25 @@ local SW, SH = guiGetScreenSize()
55
local window, window2
66

77
local savedFileName, secretKey, savedFileList
8+
local scriptVersion
89

910
addEvent(thisResName..":openMenu", true)
1011
addEvent(thisResName..":loadFileListFromServer", true)
1112

1213
addEventHandler(thisResName..":loadFileListFromServer", localPlayer, function(flist)
1314
savedFileList = flist
1415
setElementData(localPlayer, thisResName..":savedFileList", savedFileList, false)
15-
local c = 0
16-
for _ in pairs(savedFileList) do c = c + 1 end
17-
outputChatBox("Loaded "..c.." files from server", 25,255,25)
1816
if not (isElement(window) or isElement(window2)) then
19-
outputChatBox("Feel free to open the menu now.", 180,180,180)
17+
openMenu()
18+
else
19+
outputChatBox("Re-open the menu to see the updated file list", 180,180,180)
2020
end
2121
end, false)
2222

23-
function openMenu(version)
23+
function openMenu(versionFromServer)
24+
if versionFromServer then
25+
scriptVersion = versionFromServer
26+
end
2427
closeMenu()
2528

2629
guiSetInputMode("no_binds_when_editing")
@@ -51,7 +54,7 @@ function openMenu(version)
5154
end
5255

5356
local WW, WH = SW * 0.5, SH * 0.8
54-
window = guiCreateWindow(SW/2 - WW/2, SH/2 - WH/2, WW, WH, "NandoCrypt ("..version..")", false)
57+
window = guiCreateWindow(SW/2 - WW/2, SH/2 - WH/2, WW, WH, "NandoCrypt ("..scriptVersion..")", false)
5558
guiSetAlpha(window, 0.9)
5659

5760
local close = guiCreateButton(10, WH-40, WW-20, 30, "Close", false, window)
@@ -147,7 +150,7 @@ function openMenu(version)
147150
local filePath = guiGridListGetItemText(fileList_grid, row, 1)
148151
savedFileList[filePath] = nil
149152
setElementData(localPlayer, thisResName..":savedFileList", savedFileList, false)
150-
openMenu(version)
153+
openMenu()
151154

152155
elseif source == addFile then
153156

@@ -159,7 +162,7 @@ function openMenu(version)
159162
if not savedFileList then savedFileList = {} end
160163
savedFileList[filePath] = true
161164
setElementData(localPlayer, thisResName..":savedFileList", savedFileList, false)
162-
openMenu(version)
165+
openMenu()
163166

164167
elseif source == encrypt or source == decrypt then
165168

nando_crypt/files/.keep

Whitespace-only changes.

nando_crypt/s_encrypt.lua

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ local COMPILE_URL = "https://luac.mtasa.com/?compile=1&debug=0&obfuscate=3"
1616
addEvent(thisResName..":requestDecryptFile", true)
1717
addEvent(thisResName..":requestEncryptFile", true)
1818

19-
function compileCallback(responseData, responseError, fn, player)
19+
function compileCallback(responseData, responseInfo, fn, player)
2020

2121
local errorCodes = {
2222
["ERROR Nothing to do - Please select compile and/or obfuscate"] = true,
@@ -26,7 +26,7 @@ function compileCallback(responseData, responseError, fn, player)
2626
["ERROR Already encrypted"] = true,
2727
}
2828

29-
if responseError == 0 then
29+
if responseInfo.success then
3030

3131
if errorCodes[responseData] == true then
3232
return outputChatBox("#ffffffLuac: #ff0000'"..fn.."' failed to compile: "..responseData, player, 255,255,255, true)
@@ -80,7 +80,7 @@ function encryptFile(fpath, secretKey, player)
8080
end
8181
local encodedContentHash = md5(encoded)
8282

83-
local ivList
83+
local ivList = {}
8484
local kfn = FN_DECRYPTER_KEYS
8585
local kf
8686
local opened = false
@@ -101,12 +101,10 @@ function encryptFile(fpath, secretKey, player)
101101
end
102102
if kfJson ~= "" then
103103
ivList = fromJSON(kfJson)
104-
end
105-
106-
if not ivList then
107-
iprint(kfJson)
108-
outputChatBox("Failed to read IV keys from: "..kfn, player, 255,25,25)
109-
return false
104+
if not ivList then
105+
outputChatBox("Failed to read IV keys from: "..kfn, player, 255,25,25)
106+
return false
107+
end
110108
end
111109
fileDelete(kfn)
112110
end
@@ -239,9 +237,12 @@ local function getFilesInFolderRecursively(parentPath, folderName)
239237
parentFolder = folderName
240238
end
241239
for _, fileOrFolder in pairs(pathListDir(parentFolder) or {}) do
242-
if pathIsFile(fileOrFolder) then
243-
files[#files+1] = parentFolder.."/"..fileOrFolder
244-
elseif pathIsDirectory(fileOrFolder) then
240+
local thisPath = parentFolder.."/"..fileOrFolder
241+
if pathIsFile(thisPath) then
242+
if not (fileOrFolder == '.keep') then
243+
files[#files+1] = thisPath
244+
end
245+
elseif pathIsDirectory(thisPath) then
245246
local subFiles = getFilesInFolderRecursively(parentFolder, fileOrFolder)
246247
for _, subFile in pairs(subFiles) do
247248
files[#files+1] = subFile
@@ -258,11 +259,13 @@ local function requestMenu(thePlayer, cmd, option)
258259
if option == 'menu' then
259260
triggerClientEvent(thePlayer, thisResName..":openMenu", thePlayer, scriptVersion)
260261
elseif option == 'loadfiles' then
261-
local files = getFilesInFolderRecursively(false, "files")
262+
local files = getFilesInFolderRecursively(nil, "files")
262263
local files2 = {}
263264
for _, file in pairs(files) do
264265
files2[file] = true
266+
outputChatBox(" - ".. file, thePlayer, 187,187,187)
265267
end
268+
outputChatBox("Found "..#files.." files inside the files folder", thePlayer, 25,255,25)
266269
triggerClientEvent(thePlayer, thisResName..":loadFileListFromServer", thePlayer, files2)
267270
end
268271
end
@@ -310,7 +313,11 @@ function requestEncryptFile(filePaths, secretKey)
310313
return outputChatBox("File is empty: "..fn, client, 255,25,25)
311314
end
312315
outputChatBox("Compiling '"..fn.."'..", client, 75,255,75)
313-
fetchRemote(COMPILE_URL, compileCallback, {content, true, fn, client})
316+
fetchRemote(COMPILE_URL, {
317+
queueName='nandocrypt_comp',
318+
method="POST",
319+
postData=content,
320+
}, compileCallback, {fn, client})
314321
end
315322
end
316323
addEventHandler(thisResName..":requestEncryptFile", resourceRoot, requestEncryptFile, false)

0 commit comments

Comments
 (0)