简体   繁体   English

用于Android许可的AESObfuscator

[英]AESObfuscator for Android Licensing

I'm using AESObfuscator in the ServerManagedPolicy for android licensing. 我在ServerManagedPolicy中使用AESObfuscator进行Android许可。 Until now, I've created the deviceId like this: 到目前为止,我已经像这样创建了deviceId:

String deviceId = Secure.getString( getContentResolver(), Secure.ANDROID_ID );

In all the examples on the internet it is done like this, but sometimes it is stated that it isn't very safe, but no other way is described. 在Internet上的所有示例中,都是这样做的,但是有时会指出它不是很安全,但是没有描述其他方式。 I have read that ANDROID_ID can be easily changed or can even be null, so I really want to have another way to get a unique id. 我已经阅读过ANDROID_ID可以轻松更改,甚至可以为null,因此我真的想以另一种方式获取唯一ID。 The licensing failed more than once for someone who has bought my app and I'm quite sure that it has to do with this, otherwise it can only be a problem with google, what I really doubt. 对于购买了我的应用程序的人来说,许可多次失败了,我很确定这与这样做有关,否则,这只会​​是google的问题,我真的对此表示怀疑。

So how can I do this? 那我该怎么做呢? Just create a random hash and add it to the deviceId (and of course store it somewhere..?) 只需创建一个随机哈希并将其添加到deviceId(当然,将其存储在某个位置即可。)?

What do you mean by 'safe'? “安全”是什么意思? It's just a matter of obfuscating your preferences to make it harder to edit on a rooted device. 这只是混淆您的首选项,使在有根设备上进行编辑变得更加困难。 The ANDROID_ID can change if you reset your device (delete all data), or if someone edits it on a rooted device. 如果您重置设备(删除所有数据),或者有人在有根设备上进行编辑,则ANDROID_ID可能会更改。 The first case is not really a problem, in the second, you won't be able to decrypt(de-obfuscate) the stored preferences, so you just treat this as an error. 第一种情况并不是真正的问题,第二种情况您将无法解密(反模糊化)存储的首选项,因此您只能将其视为错误。 If it is really null, you should think of some sort of a fallback value. 如果确实为空,则应考虑某种后备值。

The point here is not to have a unique ID, but to use some device-specific data to obfuscate the preferences, so that you cannot just copy them to another device. 这里的重点不是拥有唯一的ID,而是使用一些特定于设备的数据来混淆首选项,因此您不能仅将它们复制到另一台设备上。 You could use a hash of the IMEI, the WiFi adapter MAC address or anything else device specific, but you have to handle the case of the particular property not being available (eg, WiFi-only tablets don't have an IMEI, etc.) 您可以使用IMEI的哈希值,WiFi适配器MAC地址或其他任何特定于设备的名称,但是必须处理特定属性不可用的情况(例如,仅WiFi平板电脑没有IMEI等)。 )

Use an error reporting library such as ACRA or BugSense to track the actual errors and understand the real cause behind licensing failing. 使用错误报告库(例如ACRA或BugSense)跟踪实际错误并了解许可失败的真正原因。 Sometimes it's the Google infrastructure's fault, so you should try to handle this as well (cache licensing status, etc.) 有时,这是Google基础架构的问题,因此您也应该尝试解决此问题(缓存许可状态等)

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

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