- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在关注 this tutorial为系统生成唯一的硬件 ID。问题是生成的 ID 在连接互联网时是不同的,而在互联网断开连接时是不同的。
这是我正在使用的代码:
private static string fingerPrint = string.Empty;
public static string GetUniqueID()
{
if (string.IsNullOrEmpty(fingerPrint))
{
fingerPrint = GetHash("CPU " + cpuId() + "\nBIOS " +
biosId() + "\nBASE " + baseId()
+ "\nVIDEO " + videoId() +"\nMAC "+ macId()
);
}
return fingerPrint;
}
private static string GetHash(string s)
{
MD5 sec = new MD5CryptoServiceProvider();
ASCIIEncoding enc = new ASCIIEncoding();
byte[] bt = enc.GetBytes(s);
return GetHexString(sec.ComputeHash(bt));
}
private static string GetHexString(byte[] bt)
{
string s = string.Empty;
for (int i = 0; i < bt.Length; i++)
{
byte b = bt[i];
int n, n1, n2;
n = (int)b;
n1 = n & 15;
n2 = (n >> 4) & 15;
if (n2 > 9)
s += ((char)(n2 - 10 + (int)'A')).ToString();
else
s += n2.ToString();
if (n1 > 9)
s += ((char)(n1 - 10 + (int)'A')).ToString();
else
s += n1.ToString();
if ((i + 1) != bt.Length && (i + 1) % 2 == 0) s += "-";
}
return s;
}
private static string identifier
(string wmiClass, string wmiProperty, string wmiMustBeTrue)
{
string result = "";
System.Management.ManagementClass mc =
new System.Management.ManagementClass(wmiClass);
System.Management.ManagementObjectCollection moc = mc.GetInstances();
foreach (System.Management.ManagementObject mo in moc)
{
if (mo[wmiMustBeTrue].ToString() == "True")
{
//Only get the first one
if (result == "")
{
try
{
result = mo[wmiProperty].ToString();
break;
}
catch
{
}
}
}
}
return result;
}
private static string identifier(string wmiClass, string wmiProperty)
{
string result = "";
System.Management.ManagementClass mc =
new System.Management.ManagementClass(wmiClass);
System.Management.ManagementObjectCollection moc = mc.GetInstances();
foreach (System.Management.ManagementObject mo in moc)
{
if (result == "")
{
try
{
result = mo[wmiProperty].ToString();
break;
}
catch
{
}
}
}
return result;
}
private static string cpuId()
{
string retVal = identifier("Win32_Processor", "UniqueId");
if (retVal == "")
{
retVal = identifier("Win32_Processor", "ProcessorId");
if (retVal == "")
{
retVal = identifier("Win32_Processor", "Name");
if (retVal == "")
{
retVal = identifier("Win32_Processor", "Manufacturer");
}
retVal += identifier("Win32_Processor", "MaxClockSpeed");
}
}
return retVal;
}
private static string biosId()
{
return identifier("Win32_BIOS", "Manufacturer")
+ identifier("Win32_BIOS", "SMBIOSBIOSVersion")
+ identifier("Win32_BIOS", "IdentificationCode")
+ identifier("Win32_BIOS", "SerialNumber")
+ identifier("Win32_BIOS", "ReleaseDate")
+ identifier("Win32_BIOS", "Version");
}
private static string diskId()
{
return identifier("Win32_DiskDrive", "Model")
+ identifier("Win32_DiskDrive", "Manufacturer")
+ identifier("Win32_DiskDrive", "Signature")
+ identifier("Win32_DiskDrive", "TotalHeads");
}
private static string baseId()
{
return identifier("Win32_BaseBoard", "Model")
+ identifier("Win32_BaseBoard", "Manufacturer")
+ identifier("Win32_BaseBoard", "Name")
+ identifier("Win32_BaseBoard", "SerialNumber");
}
private static string videoId()
{
return identifier("Win32_VideoController", "DriverVersion")
+ identifier("Win32_VideoController", "Name");
}
private static string macId()
{
return identifier("Win32_NetworkAdapterConfiguration",
"MACAddress", "IPEnabled");
}
GetUniqueID()
是散列各种 ID 的函数。为什么在有网络和没有网络的情况下生成的 ID 不同?
最佳答案
我认为这是因为当您断开连接时,您的网络接口(interface)被禁用,因此无法检索 MAC 地址。
关于c# - 为什么我的 ID 会随着互联网连接而改变?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48973748/
最近两年,互联网+的概念可谓十分火爆。所谓“互联网+”,其实质就是把互联网大平台和各行各业进行有机结合,建立一个新的商业生态,对于传统企业来说,互联网+的第一步就是有一个企业网站,将自己推广出去
我的大学分两步运行他们的 wifi 身份验证。首先您连接到 wifi 网络,然后当您打开网络浏览器时,您必须输入一些关于您自己的附加信息才能访问互联网。 1)大学系统有一些方法可以检测设备之前是否已经
有没有办法监控每个应用程序使用了多少数据(互联网)? 如果我无法监控应用程序,是否有办法获取所有互联网请求信息?(获取传递的数据、url 等) (我想在为 iPhone 开发的应用程序中使用此信息)
我想从我的 MTI RFID ME Gen2 Internet 中读出一些标签: http://www.mti.com.tw/rfidme/ 这是一个 USB Dongle,现在我想用 c# 在 VS
我正在开发一个应用程序。其中,我想在一段时间内禁止使用互联网,尤其是在他有作业的情况下。如何禁用互联网? 最佳答案 要以编程方式启用/禁用数据连接,请检查此 post 要禁用/启用 wi-fi,请参阅
在我的应用程序中,我只需要知道设备是否连接到 wifi 网络。我认为此功能适用于模拟器但不适用于真实设备。 public static boolean wifiInternet(Context c)
关闭。这个问题是off-topic .它目前不接受答案。 想改进这个问题吗? Update the question所以它是on-topic用于堆栈溢出。 关闭 12 年前。 Improve th
设想一种情况,我的 PC 有两个网卡,一个连接到互联网,另一个连接到本地网络,我如何用 C# 检测连接到互联网的 IP? 最佳答案 试试这个: static IPAddress getInternet
我的 firebase 应用程序在我的 android 设备上运行完美,无需添加 permission.INTERNET 标志。我直接从 gradle 安装了 Firebase。我知道通过 andro
最近我开始考虑一种解决方案,通过 Internet 向我的订阅客户发布消息。我们的系统是用 C# 开发的。 我们尝试使用 Redis,它在速度和准确性方面非常好,但在安全性方面非常糟糕,每个人都可以订
国内公司普遍不注重基础设施建设,这也是可以理解的。吃饭都吃不饱,就别提什么荤素搭配,两菜一汤了。但也不能全说是这样,还是有很多公司投入大量的人力物力去做好公司的基建,比如很多阿里和美团的小伙伴对公司
我有几个 Azure Functions(高级计划),它们可以执行一些操作并将结果加载到存储 blob。与存储帐户的连接受到 v-net 的限制,因此无法公开访问存储帐户,但是,我检查并发现我的 (H
我正在我的家庭有线网络上解析 ICMPv6 数据报,但在特定的 RFC 中找不到对位排序约定的明确提及。 多字节字段是网络顺序,但是一个字节内的位呢? 机器是字节可寻址的,但网络硬件将位序列化。在图表
我如何在笔记本电脑上配置以太网或 wifi,我遵循了这个 tutorial我的以太网正常启动,但我仍然无法从 ping 8.8.8.8 dns 收到任何数据包,我的笔记本电脑上有以太网和 wifi .
我在 Genymotion 模拟器上运行的应用程序需要互联网。网上好像不能用Genymotion模拟器。我试图通过打开浏览器来确认这一点,这就是我得到的: 我在笔记本电脑上运行 Windows 7 并
我目前正在学习 docker 和 kubernetes。我遇到的问题之一是将我的 nginx pod 暴露在公共(public)互联网上。我想从我的网络浏览器访问我的 serverIP 并查看 ngi
是否可以为 ImageSpan 指定 Internet url 并使用 TextView 显示它?我已经尝试了很多版本 String mockContent = ""; myTextView.setT
例子。 我在 Google 主页上做了一些 CSS 更改。我想保存 CSS(某处)并在每次加载页面时都具有相同的外观。 欢迎使用任何浏览器插件或任何其他方法。 最佳答案 如果使用谷歌浏览器,有一个名为
我正在构建一个旨在加载到 Wii Internet Channel(本质上是 Opera 9.3)的 Web 应用程序。 它支持 SVG,但它们似乎无法缩放。无论宽度和高度设置为多少,图形始终以其“最
我安装了 python 2.7.5,它工作正常。 然后我安装scrapy(我认为,它在内部使用了twisted)。我的爬虫蜘蛛也工作正常。 我安装了扭曲: sudo apt-get install p
我是一名优秀的程序员,十分优秀!