Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = {...}
- local eRegex, regexNum
- local function algorithmGen()
- local alg = {}
- repeat
- alg[1] = math.random(0, 9)
- alg[2] = math.random(-9, 0)
- alg[3] = math.random(1, 2)
- alg[4] = alg[3] == 1 and 2 or 1
- until alg[1] + alg[2] ~= 0
- return alg
- end
- function delgorithmGen()
- local rFile = fs.open(tArgs[1], "r")
- byteFile = rFile.readAll()
- rFile.close()
- local regex = {byteFile:find("([+-]?%d)([+-]?%d)(%d)(%d)$")}
- local sFile = fs.open(tArgs[1], "w")
- sFile.write(byteFile:sub(1, -(#tostring(regex[1]) + #tostring(regex[2]) + 3)))
- sFile.close()
- for i = 1, 2 do
- table.remove(regex, 1)
- end
- return regex
- end
- if tArgs[2] == "u" then
- regexNum = delgorithmGen()
- else
- eRegex = algorithmGen()
- end
- local uFile = fs.open(tArgs[1], "rb")
- local eCode = ""
- while true do
- local bData = uFile.read()
- if bData then
- if tArgs[2] == "u" then
- if regexNum[3] == 1 then
- bData = bData - regexNum[1] - regexNum[2]
- else
- bData = bData - regexNum[2] - regexNum[1]
- end
- else
- bData = bData + eRegex[eRegex[3]] + eRegex[eRegex[4]]
- end
- eCode = eCode .. string.char(bData)
- else
- break
- end
- end
- uFile.close()
- local sFile = fs.open(tArgs[1], "w")
- sFile.write(eCode)
- if tArgs[2] ~= "u" then
- sFile.write(tostring(eRegex[1]) .. tostring(eRegex[2]) .. tostring(eRegex[3]) .. tostring(eRegex[4]))
- end
- sFile.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement