Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- key = get ("key") or 1251232132342134
- function encode(name)
- local count, meta = fileOpenAndMath (name)
- if count == 0 then return end
- for i = 0, count do
- local info = xmlFindChild (meta, "file", i)
- if info then
- for data, v in pairs (xmlNodeGetAttributes(info)) do
- if data == "src" then
- local s, e = string.find (v, ".dff")
- if s == nil or e == nil then s, e = string.find (v, ".txd") end
- if s ~= nil and e ~= nil then
- local path = ":"..name.."/"..v
- local file = fileOpen (path)
- local buffer = fileRead(file, fileGetSize(file))
- local encript = teaEncode( base64Encode( buffer ), key )
- fileDelete (path)
- local newFile = fileCreate (path)
- fileWrite (newFile, encript)
- fileClose (newFile)
- end
- end
- end
- end
- end
- outputChatBox ("Ресурс зашифрован!", root, 0, 255, 0)
- end
- addEvent("encode", true)
- addEventHandler("encode", root, encode)
- function fileOpenAndMath (name)
- local count = 0
- local res = getResourceFromName (tostring(name))
- assert (res, "Not resource with name '"..name.."'!")
- local meta = xmlLoadFile (":"..name.."/meta.xml")
- assert (meta, "Not meta.xml in resource '"..name.."'!")
- local children = xmlNodeGetChildren (meta)
- for k, data in ipairs (children) do
- if xmlNodeGetName (data) == "file" then
- count = count + 1
- end
- end
- return count, meta
- end
- function decode(name)
- local count, meta = fileOpenAndMath (name)
- if count == 0 then return end
- for i = 0, count do
- local info = xmlFindChild (meta, "file", i)
- if info then
- for data, v in pairs (xmlNodeGetAttributes(info)) do
- if data == "src" then
- local s, e = string.find (v, ".dff")
- if s == nil or e == nil then s, e = string.find (v, ".txd") end
- if s ~= nil and e ~= nil then
- local path = ":"..name.."/"..v
- local file = fileOpen (path)
- local buffer = fileRead(file, fileGetSize(file))
- local encript = base64Decode(teaDecode(buffer,key))
- fileDelete (path)
- local newFile = fileCreate (path)
- fileWrite (newFile, encript)
- fileClose (newFile)
- end
- end
- end
- end
- end
- outputChatBox ("Ресурс расшифрован!", root, 0, 255, 0)
- end
- addEvent("decode", true)
- addEventHandler("decode", root, decode)
- function replaceCarServr (file)
- local buffer = fileRead(file, fileGetSize(file))
- local encript = base64Decode(teaDecode(buffer,key))
- return encript
- end
- addEvent ("replaceCarServr", true)
- addEventHandler ("replaceCarServr", root, replaceCarServr)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement