Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local sKey = "your_key_here"; -- Максимальная длина - 16 символов, можно больше, но смысла нет. Читаться будут только первые 16 символов.
- local iCountBytes = 1000;
- -- CODING
- addEventHandler( "onResourceStart", resourceRoot,
- function()
- local XML = xmlLoadFile( "meta.xml" );
- local Childrens = xmlNodeGetChildren( XML );
- for Index, Child in ipairs( Childrens ) do
- local Name = xmlNodeGetName( Child );
- if Name == "file" then
- local Attributes = xmlNodeGetAttributes( Child );
- local FilePath = Attributes.src;
- local pFile = fileOpen( FilePath )
- local FirstPart = fileRead( pFile, 65536 )
- fileSetPos( pFile, 65536 )
- local SecondPart = fileRead( pFile, iCountBytes )
- local SecondPartConverted = ""
- local aTable = {}
- for i = 1, iCountBytes do
- local sString = string.sub( SecondPart, i )
- local iByte = string.byte( sString )
- SecondPartConverted = SecondPartConverted..teaEncode( iByte, sKey )
- end
- fileSetPos( pFile, 65536+iCountBytes )
- local ThirdPart = fileRead( pFile, fileGetSize( pFile ) - (65536+iCountBytes) )
- local sResult = FirstPart..SecondPartConverted..ThirdPart
- fileClose( pFile )
- local FileName = string.gsub( FilePath, "FILES_TO_ENCODE/", "" );
- if fileExists( "ENCDODED_FILES/"..FileName ) then
- fileDelete( "ENCDODED_FILES/"..FileName )
- end
- pFile = fileCreate( "ENCDODED_FILES/"..FileName )
- fileWrite( pFile, sResult )
- fileClose( pFile )
- end
- end
- end
- )
- -- UNCODING
- local XML = xmlLoadFile( "meta.xml" );
- for Index, Table in ipairs( g_DffReplaces ) do
- local pFile = fileOpen( Table[1] );
- local FirstPart = fileRead( pFile, 65536 )
- fileSetPos( pFile, 65536 )
- local SecondPart = fileRead( pFile, iCountBytes * 12 );
- local SecondPartConverted = ""
- for i = 1, iCountBytes do
- local iTo = i * 12
- local iFrom = iTo - 11
- local sConvertedString = string.sub( SecondPart, iFrom, iTo )
- local iDecodedNumber = tonumber( teaDecode( sConvertedString, Key ) )
- local sChar = string.char( iDecodedNumber )
- SecondPartConverted = SecondPartConverted..sChar
- end
- fileSetPos( pFile, 65536+iCountBytes*12 )
- local ThirdPart = fileRead( pFile, fileGetSize( pFile ) - (65536+iCountBytes*12) )
- local sResult = FirstPart..SecondPartConverted..ThirdPart
- local DFF = engineLoadDFF( sResult );
- engineReplaceModel( DFF, Table[2] );
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement