平时在开发软件过程中,很多时候需要生成机器码和系列号。怎么样利用网卡MAC生成机器码和系列号呢?以下是个人按照自己的思路写的一段代码,写得不好莫怪。贴出来也是给大伙一个思路和参考。
//定义全局变量
$get_string = "ASDFWEHUIOJHJHPF";//加密参与字符
function strtomd5_pass($str)
{
global $get_string;
return md5(md5($str.$get_string).$get_string);
}
@exec("ipconfig /all",$array);
for($Tmpa;$Tmpa
{
if(eregi("Physical",$array[$Tmpa]))
{
$mac=explode(":",$array[$Tmpa]);
$macstr = trim($mac[1]);
}
}
$macmd5str = substr(strtomd5_pass($macstr),0,24);
$macmd5str = strtoupper($macmd5str);
$robotstr = substr($macmd5str,0,6)."-".substr($macmd5str,4,6)."-".substr($macmd5str,8,6)."-".substr($macmd5str,12,6);
$macmd5towstr = substr(strtomd5_pass($robotstr),0,24);
$macmd5towstr = strtoupper($macmd5towstr);
$robotwostr = substr($macmd5towstr,0,6)."-".substr($macmd5towstr,4,6)."-".substr($macmd5towstr,8,6)."-".substr($macmd5towstr,12,6);
echo "机器码:".$robotstr;
echo "
";
echo "系列号:".$robotwostr;
?>
注明:本文由网络雏鹰原创。