如果不是,请使用“IPHONE UDID”? [英] What to use if not "IPHONE UDID"?
本文介绍了如果不是,请使用“IPHONE UDID”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
哇...看看本周在线使用iPhone的UDID的所有恐慌故事。
[[ UIDevice currentDevice] uniqueIdentifier]
我们正在使用什么? p>
如果手机出售给另一个用户...而应用程序已经根据手机的UDID存储了一些数据在远程服务器上?
(当然,我想避免应用商店的加密限制的问题。)
解决方案
有一个很好的UIDevice扩展类别 here
- (NSString *)macaddress
{
int mib [6];
size_t len;
char * buf;
unsigned char * ptr;
struct if_msghdr * ifm;
struct sockaddr_dl * sdl;
mib [0] = CTL_NET;
mib [1] = AF_ROUTE;
mib [2] = 0;
mib [3] = AF_LINK;
mib [4] = NET_RT_IFLIST;
if((mib [5] = if_nametoindex(en0))== 0){
printf(Error:if_nametoindex error\\\
);
返回NULL;
}
if(sysctl(mib,6,NULL,& len,NULL,0)< 0){
printf(Error:sysctl,take 1\\ \
);
返回NULL;
}
if((buf = malloc(len))== NULL){
printf(无法分配内存错误!\\\
);
返回NULL;
}
if(sysctl(mib,6,buf,& len,NULL,0)< 0){
printf(Error:sysctl,take 2 );
返回NULL;
}
ifm =(struct if_msghdr *)buf;
sdl =(struct sockaddr_dl *)(ifm + 1);
ptr =(unsigned char *)LLADDR(sdl);
NSString * outstring = [NSString stringWithFormat:@%02X:%02X:%02X:%02X:%02X:%02X,
* ptr,*(ptr + 1),* +2),*(ptr + 3),*(ptr + 4),*(ptr + 5)];
// NSString * outstring = [NSString stringWithFormat:@%02X%02X%02X%02X%02X%02X,
// * ptr,*(ptr + 1),*(ptr + 2),*(ptr + 3),*(ptr + 4),*(ptr + 5)];
免费(buf);
返回outstring;
}
你可以用模型来填充这个?
Wow... look at all the "panic stories" online this week regarding using an iPhone's UDID.
[[UIDevice currentDevice] uniqueIdentifier]
What SHOULD we be using instead?
What if the phone is sold to another user... and an app has stored some data on a remote server, based on the phone's UDID?
(Of course, I want to avoid the problems with the app store's "encryption restrictions".)
解决方案
Why not use the Mac Address and possibly then hash it up.
There is an excellent UIDevice-Extension Category here
- (NSString *) macaddress
{
int mib[6];
size_t len;
char *buf;
unsigned char *ptr;
struct if_msghdr *ifm;
struct sockaddr_dl *sdl;
mib[0] = CTL_NET;
mib[1] = AF_ROUTE;
mib[2] = 0;
mib[3] = AF_LINK;
mib[4] = NET_RT_IFLIST;
if ((mib[5] = if_nametoindex("en0")) == 0) {
printf("Error: if_nametoindex error\n");
return NULL;
}
if (sysctl(mib, 6, NULL, &len, NULL, 0) < 0) {
printf("Error: sysctl, take 1\n");
return NULL;
}
if ((buf = malloc(len)) == NULL) {
printf("Could not allocate memory. error!\n");
return NULL;
}
if (sysctl(mib, 6, buf, &len, NULL, 0) < 0) {
printf("Error: sysctl, take 2");
return NULL;
}
ifm = (struct if_msghdr *)buf;
sdl = (struct sockaddr_dl *)(ifm + 1);
ptr = (unsigned char *)LLADDR(sdl);
NSString *outstring = [NSString stringWithFormat:@"%02X:%02X:%02X:%02X:%02X:%02X",
*ptr, *(ptr+1), *(ptr+2), *(ptr+3), *(ptr+4), *(ptr+5)];
// NSString *outstring = [NSString stringWithFormat:@"%02X%02X%02X%02X%02X%02X",
// *ptr, *(ptr+1), *(ptr+2), *(ptr+3), *(ptr+4), *(ptr+5)];
free(buf);
return outstring;
}
You could possibly hash this with the model?
这篇关于如果不是,请使用“IPHONE UDID”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文