注意----下面的答案使用iOS6-方法,Apple从那时起删除了开发人员对MAC地址的访问权限。如果您正在为 iOS7+ 开发,请忽略第一个答案,而只是根据每个设备独有的其他变量(例如应用程序首次启动的日期)加密您的 IAP 解锁数据
我有需要解锁音调的功能,所以我将它们存储在我的 plist 文件中.... 像聊天室中的新头像这样的功能可能具有 id “13891”,如果它已解锁,我可能会为其分配一些键,如“93 “如果它被锁定,它可能有任何其他键“37”例如......所以plist会说:“13891”=“93”我的问题是越狱手机可以轻松编辑plist文件并为自己解锁功能吗?存储这些数据的更好方法是什么?我不想每次都检查 Apple 的服务器,因为互联网连接速度太慢,这需要很长时间。
编辑:当前答案:
4 措施:
1)将其存储在钥匙串中。(或者我想现在我已经添加了措施#4)
2) 每次都检查 Apple 的服务器,但如果您担心随后的延迟,只需在后台检查它,同时让用户使用该应用程序,如果它说可以的话。
3)将您的变量作为加密密钥存储在钥匙串中......不要存储“FishingRod = unlocked”存储“3dhk34D@HT% = d3tD@#”。
4) 使用设备 MAC 地址加密每个密钥(这些 MAC 地址不会更改,并且无论是否有 WiFi 连接都可用......下面的代码)。这样,如果用户从 Internet 下载 plist 并尝试使用它,它将无法正常工作,因为当您使用他们的设备 ID 对其进行解密时,您将无法随机废话而不是解锁密钥(在我的示例中将是“d3tD@#”。)!!!-- 从 iOS7+ 起无法再访问 Mac 地址,而是使用其他设备独有的东西加密,例如应用程序首次启动的日期
MAC 地址代码(只需将其粘贴在 .H 导入中的视图控制器 ViewDidAppear... 中)
#include <sys/socket.h>
#include <sys/sysctl.h>
#include <net/if.h>
#include <net/if_dl.h>
-(void)viewDidAppear:(BOOL)animated {
int mgmtInfoBase[6];
char *msgBuffer = NULL;
NSString *errorFlag = NULL;
size_t length;
// Setup the management Information Base (mib)
mgmtInfoBase[0] = CTL_NET; // Request network subsystem
mgmtInfoBase[1] = AF_ROUTE; // Routing table info
mgmtInfoBase[2] = 0;
mgmtInfoBase[3] = AF_LINK; // Request link layer information
mgmtInfoBase[4] = NET_RT_IFLIST; // Request all configured interfaces
// With all configured interfaces requested, get handle index
if ((mgmtInfoBase[5] = if_nametoindex("en0")) == 0)
errorFlag = @"if_nametoindex failure";
// Get the size of the data available (store in len)
else if (sysctl(mgmtInfoBase, 6, NULL, &length, NULL, 0) < 0)
errorFlag = @"sysctl mgmtInfoBase failure";
// Alloc memory based on above call
else if ((msgBuffer = malloc(length)) == NULL)
errorFlag = @"buffer allocation failure";
// Get system information, store in buffer
else if (sysctl(mgmtInfoBase, 6, msgBuffer, &length, NULL, 0) < 0)
{
free(msgBuffer);
errorFlag = @"sysctl msgBuffer failure";
}
else
{
// Map msgbuffer to interface message structure
struct if_msghdr *interfaceMsgStruct = (struct if_msghdr *) msgBuffer;
// Map to link-level socket structure
struct sockaddr_dl *socketStruct = (struct sockaddr_dl *) (interfaceMsgStruct + 1);
// Copy link layer address data in socket structure to an array
unsigned char macAddress[6];
memcpy(&macAddress, socketStruct->sdl_data + socketStruct->sdl_nlen, 6);
// Read from char array into a string object, into traditional Mac address format
NSString *macAddressString = [NSString stringWithFormat:@"%02X:%02X:%02X:%02X:%02X:%02X",
macAddress[0], macAddress[1], macAddress[2], macAddress[3], macAddress[4], macAddress[5]];
NSLog(@"Mac Address: %@", macAddressString);
// Release the buffer memory
free(msgBuffer);
//return macAddressString;
NSLog(@"MAC: %@", macAddressString);
//F0:DC:E2:1D:EB:50
}
// Error...
NSLog(@"Error: %@", errorFlag);
}
注意:我从朋友那里得到了 MAC 地址代码……我并不是说我编写了代码……我不知道是他编写的还是从其他人那里得到的。