Unique Device ID UWP

2019-07-16 00:29发布

Since few days I am trying to get MAC Adress from my Windows Phone device withouse success. I am trying to get UNIQUE ID for my Phone, Tablet etc. I`ve found HardwareToken class and the code below

HardwareToken token = HardwareIdentification.GetPackageSpecificToken(null);
                IBuffer hardwareId = token.Id;
                HashAlgorithmProvider hasher = HashAlgorithmProvider.OpenAlgorithm("MD5");
                IBuffer hashed = hasher.HashData(hardwareId);
                string hashedString = CryptographicBuffer.EncodeToHexString(hashed);

Using this code I am reciving ASHWID. Is that really unique?

2条回答
做自己的国王
2楼-- · 2019-07-16 00:50

the ASHWID is qualified as sufficiently unique. You can rely on it IMHO. Check this reference article to get deep knowledge on the ASHWID https://msdn.microsoft.com/en-us/jj553431

查看更多
smile是对你的礼貌
3楼-- · 2019-07-16 00:57

Using this code I am receiving ASHWID. Is that really unique?

It depends. On phone/tablet more likely than on desktop. The exact answer you can found at MSDN:

The ASHWID provides a strong binding between the app/package and the device by representing several individual hardware characteristics. In order to protect user privacy, the ASHWID varies from app to app. Unless the underlying hardware has changed, two calls from the same app will result in identical ASHWIDs. However, the ASHWID changes if the hardware profile of the device changes, such as when the user unplugs a USB Bluetooth adapter. The back-end cloud service can verify the ASHWID and compare it with previously reported values.

Following Peter's Torr answer you should also check first if that API is present on actual device. Though you may also think about his advice - to think if that really is a solution to your problem.

查看更多
登录 后发表回答