Talk:Source Obfuscation

Custom compiled LOVE with encryption

What about modifying LOVE Filesystem code to load encrypted Lua files?

The files that must be edited is src/modules/filesystem/wrap_Filesystem.cpp w_load function

int w_load(lua_State *L)
	std::string filename = std::string(luaL_checkstring(L, 1));
	Data *data = nullptr;
		data = instance()->read(filename.c_str());
	catch (love::Exception &e)
		return luax_ioError(L, "%s", e.what());
	// Decrypt the contents of "data->getData()" before supplying it to luaL_loadbuffer.
	// You may also consider of using custom lua_Reader function and use lua_load instead.
	// Basically, decrypt your code before line below.
	// Example below.
	Data *decryptedData = decryptLuaScript(data); // Decrypt data function
	int status = luaL_loadbuffer(L, (const char *)decryptedData->getData(), decryptedData->getSize(), ("@" + filename).c_str());
	decryptedData->release(); // Release the decrypted data object
	// Load the chunk, but don't run it.
	switch (status)
		return luaL_error(L, "Memory allocation error: %s\n", lua_tostring(L, -1));
		return luaL_error(L, "Syntax error: %s\n", lua_tostring(L, -1));
	default: // success
		return 1;

The changes also reflect to LOVE "require" loader, since it uses w_load function internally.

I still doubt if it's good to apply it to assets, since doing it requires you to create new LOVE class like "EncryptedFileData" or something like that and expose it to Lua API.

-- User:AuahDark