简体   繁体   English

使用钥匙串存储高分和加电

[英]Using keychain to store high scores and power ups

I'm wanting a more secure way to store high scores and power ups like stars/coins than using UserDefaults (which I believe can be altered by end user). 我想要一种更安全的方式来存储高分和像星星/硬币这样的能量比使用UserDefaults(我相信最终用户可以改变)。 I've seen the keychain mentioned as an alternative and after reading a little about it I get the impression it's main purpose is for storing passwords. 我已经看到了作为替代方案提到的钥匙链,在阅读了一些关于它之后,我得到的印象是它的主要目的是存储密码。

1, Is it ok to use the keychain for this purpose? 1,为此可以使用钥匙串吗? 2, How much data can you realistically store? 2,您可以实际存储多少数据? 3, Is it ok to write many changes to it very quickly, eg. 3,可以很快地对其进行很多更改,例如。 Several times a second? 一次几次? 4, I believe there's many open source classes to deal with the keychain. 4,我相信有许多开源类来处理钥匙串。 Which is the best to use? 哪个最好用?

Thanks 谢谢

Instead of storing highscores into a place where they don't belong, you might consider hashing them. 您可以考虑散列它们,而不是将高分存储到它们不属于的地方。 If you read the highscore again, also compare the hash with a recalculated one. 如果再次读取高分,还要将哈希值与重新计算的哈希值进行比较。 If they don't match, the highscore has been tampered with and you can blame the player for trying to cheat. 如果他们不匹配,高分已被篡改,你可以责怪球员试图作弊。 The hashing algorithm can be something very sophisticated like SHA, or you can think of a simpler one yourself. 散列算法可以像SHA一样非常复杂,或者您可以自己想一个更简单的算法。 I suppose it doesn't have to be too bullet proof for game scores. 我认为它不一定是游戏分数太过防弹。

Maybe this thread helps: How to secure NSUserDefaults? 也许这个帖子有帮助: 如何保护NSUserDefaults?

They mention Secure-NSUserDefaults ctagory but I haven't used it yet. 他们提到了Secure-NSUserDefaults ctagory但我尚未使用它。 Though thanks for the question, that reminded me to use keychain in my apps too! 虽然感谢这个问题,但这也提醒我在我的应用程序中也使用钥匙串!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM