我正在使用LibGDX框架开发游戏。我想知道如何使游戏更安全。例如,有根android设备的用户可以更改保存.xml文件,这样游戏就会被黑,或者他/她可以使用GameKiller或类似的程序,并改变游戏运行时的值(金钱、exp等)。那我怎么才能阻止这些呢?
与桌面版本相同的是,保存文件不隐藏,玩家也可以在PC上找到该文件。并且可以使用CheatEngine或其他程序进行黑客攻击,并再次更改运行时值。
发布于 2015-10-18 14:46:22
如果您不存储私有/重要数据,而只想使您的游戏难以破解(例如,通过使用游戏级别更改xml ),则可以在GWT密码库上实现加密基础。
初始化加密程序的方式是:
//this will be used for encrypting and decrypting strings
private TripleDesCipher encryptor;
...
//creating key for encryptor
TripleDesKeyGenerator generator = new TripleDesKeyGenerator();
byte[] key = generator.decodeKey("04578a8f0be3a7109d9e5e86839e3bc41654927034df92ec"); //you can pass your own string here
//initializing encryptor with generated key
encryptor = new TripleDesCipher();
encryptor.setKey(key);
...以及使用方法:
private String encryptString(String string)
{
try
{
string = encryptor.encrypt( string );
}
catch (DataLengthException e1)
{
e1.printStackTrace();
}
catch (IllegalStateException e1)
{
e1.printStackTrace();
}
catch (InvalidCipherTextException e1)
{
e1.printStackTrace();
}
return string;
}
private String decryptString(String string)
{
try
{
string = encryptor.decrypt(string);
}
catch (DataLengthException e)
{
e.printStackTrace();
} catch (IllegalStateException e)
{
e.printStackTrace();
} catch (InvalidCipherTextException e)
{
e.printStackTrace();
}
return string;
}我还建议您不要使用XML,而是使用JSONs -它们更方便,重量更小。在这里阅读如何处理它。
记住,一般来说,客户端加密不是很好的想法,总是可以被黑客以某种方式-但我很肯定,如果它不是关于钱,没有人会认为它值得。
如果您对保存数据的更高级方法感兴趣,最好的方法是通过SSL发送所有数据,并将其保存在一些防护良好的服务器中--尽管我不太确定Libgdx是否有任何良好的SSL机制,也不知道我可以推荐的第三方库。
保存文件的服务示例可以是谢泼茨 (我正在使用它们的漂亮AppWarp,并打算在我的应用程序中实现这个)。
发布于 2016-08-11 22:26:33
您可以将这些用于运行时。
欺骗引擎和游戏杀手的孪生兄弟
int health=15;
int twinhealth=15;
if(HPtaken())
{
health+=10;//those twins will always change together
twinhealth+=10;
}
if(health!=twinhealth)//if they are different this means there is hack attempt
{
//punishment for hacker
}实际上,它不是一个隐秘,它只是变量上的小变化,所以黑客不可能通过游戏杀手或作弊引擎轻易地改变。
int health=15*7;
int twinhealth=15*7;
if(HPtaken())
{
health+=10*7;//those twins will always change together
twinhealth+=10*7;
}
drawhealth( health/7 );// So hacker going to see and search wrong value on cheatengine 黑客禁止冻结和改变两个双胞胎具有相同的价值。所以这对双胞胎中至少有一个会被加密。
int health=15;
int twinhealth=15*5;
if(HPtaken())
{
health+=10;//those twins will always change together
twinhealth+=10*5;
}
if(health!=twinhealth*5)//if they are different this means there is hack attempt
{
//punishment for hacker
}当然,黑客可以对你的游戏进行反编译和黑客攻击,但这会让你的游戏更难破解。顺便说一下,您可以使用随机变量来编辑变量。
您可以应用于xml或首选项,但您可以使用一些复杂的加密,因为速度不是问题,因为您只导入/导出几次。
https://stackoverflow.com/questions/33198028
复制相似问题