在客戶端認證的過程中,我們總要獲取客戶機的唯一識別資訊,曾經以為mac位址是不會變的,但是現在各種改,特別是使用無線上網絡卡,mac位址插一次變一次,所以這樣使用mac就沒有什麼意義了,怎麼辦,又開始求助google,最後找到乙個折中的方案
通過獲取主機板、處理器、bios、mac、顯示卡、硬碟等的id生成唯一識別碼
1、使用那些不經常更換的模組來生成識別碼。
2、如果經常更換mac,顯示卡,硬碟,則不要使用這些id。
3、確保使用static變數在整個應用來儲存唯一識別碼。
using參考system;
using
system.management;
using
system.security.cryptography;
using
system.security;
using
system.collections;
using
system.text;
namespace
security
return
fingerprint;
}private
static
string gethash(string
s)
private
static
string gethexstring(byte
bt)return
s; }
#region original device id getting code
//return a hardware identifier
private
static
string
identifier
(string wmiclass, string wmiproperty, string
wmimustbetrue)
catch}}
}return
result;
}//return a hardware identifier
private
static
string identifier(string wmiclass, string
wmiproperty)
catch}}
return
result;
}private
static
string
cpuid()
//add clock speed for extra security
retval += identifier("
win32_processor
", "
maxclockspeed");}}
return
retval;
}//bios identifier
private
static
string
biosid()
//main physical hard drive id
private
static
string
diskid()
//motherboard id
private
static
string
baseid()
//primary video controller id
private
static
string
videoid()
//first enabled network card id
private
static
string
macid()
#endregion
}}
現在遇到一些平板等簡陋的機型,竟然獲取到的所有裝置標識都一樣(除了mac),最後只好在本地再生成乙個軟體自身的標識,然後每次在計算標識的時候附帶上,這樣不會再重複了吧。
**如下:
private可以再把該檔案設為隱藏等手段,防止使用者誤操作。static
string
localkey()
else
}
c 獲取機器唯一識別碼
在客戶端認證的過程中,我們總要獲取客戶機的唯一識別資訊,曾經以為mac位址是不會變的,但是現在各種改,特別是使用無線上網絡卡,mac位址插一次變一次,所以這樣使用mac就沒有什麼意義了,怎麼辦,又開始求助google,最後找到乙個折中的方案 通過獲取主機板 處理器 bios mac 顯示卡 硬碟等的...
android 獲取手機唯一識別碼
如果獲取不到imsi號,就拼接其它資訊獲取唯一碼 結論是,依然有部分手機獲取不到。final telephonymanager tm telephonymanager getbasecontext getsystemservice context.telephony service string u...
獲取Android系統的唯一識別碼
摘自 在計算機上,我們習慣用mac位址來標誌一台計算機。在android裝置上,可以用imie或者android id來標誌乙個裝置。看一下android上怎樣獲取這樣的資訊。乙個是telephonymanager的getdeviceid,另外乙個是settings.system的android i...