Code
''' <summary>
''' 返回 CPU 的相关信息,包括一个参数
''' </summary>
''' <param name="mTs">返回值选项</param>
''' <returns>返回用户的CPU 编号 / 返回用户的识别码 / 返回用户识别码对应的密码</returns>
''' <remarks>引用和导入 System.Management 组件!!</remarks>
Function GetCpuInfo(ByVal mTs As String) As String
'参数:mTs 为返回值的标识
' 1.返回用户的识别码
' 2.返回用户识别码对应的密码
' 如果参数不是1,2,3中的任意一个,则视为用户的识别码,据此再生成一个密码
Dim j As String = str '连接字符串
Dim mc As ManagementClass = New ManagementClass("Win32_Processor")
Dim moc As ManagementObjectCollection = mc.GetInstances
Dim mocEn As ManagementObjectCollection.ManagementObjectEnumerator = moc.GetEnumerator
mocEn.MoveNext()
Dim mo As ManagementObject = mocEn.Current
'用户识别码算法
Dim pid As String = mo.Properties("ProcessorId").Value
Dim ysz As String = pid & "jarod"
Dim yss As String = HashPasswordForStoringInConfigFile(ysz, "Md5")
Dim ys As String = ""
'生成用户识别码(取1、3、5、4、1、7位数上的字符)
ys = yss.Substring(7, 1)
ys &= yss.Substring(1, 1)
ys &= yss.Substring(4, 1)
ys &= yss.Substring(5, 1)
ys &= yss.Substring(3, 1)
ys &= yss.Substring(1, 1)
'用户密码算法
Dim psz As String = ys + "jarod"
Dim ps As String = HashPasswordForStoringInConfigFile(psz, "Md5")
Dim ps1 As String = HashPasswordForStoringInConfigFile(ps, "Md5")
Dim pss As String = ""
'生成用户密码(去2、3、5、7、9、6位数上的字符)
pss = ps1.Substring(2, 1)
pss &= ps1.Substring(3, 1)
pss &= ps1.Substring(5, 1)
pss &= ps1.Substring(7, 1)
pss &= ps1.Substring(9, 1)
pss &= ps1.Substring(6, 1)
If mTs = "0" Then
Return ys '0.返回用户的识别码
ElseIf mTs = "1" Then
Return pss '1.返回用户识别码对应的密码
ElseIf mTs = "cpu" Then
Return pid '返回 CPU 序列号
Else
Dim pso As String = mTs & j
Dim psoo As String = HashPasswordForStoringInConfigFile(pso, "Md5")
psoo = HashPasswordForStoringInConfigFile(psoo, "Md5")
Dim psn As String = Nothing
'去2、3、5、7、9、6位数上的字符
psn = psoo.Substring(2, 1)
psn &= psoo.Substring(3, 1)
psn &= psoo.Substring(5, 1)
psn &= psoo.Substring(7, 1)
psn &= psoo.Substring(9, 1)
psn &= psoo.Substring(6, 1)
Return psn '如果参数不是1,2,3中的任意一个,则视为用户的识别码,据此再生成一个密码
End If
End Function