int Count(char * name)
{
int sum =0;
unsigned int i = 0;
for(;i<strlen(name);i++)
sum += name[i];
return sum;
}
unsigned long GetNum(char * username ,int namelen)
{
unsigned long num =namelen;
unsigned int i;
int temp=0;
for(i=namelen;i>0;i--)
{
//不能写成一个表达式,- -!
//貌似因为temp 与num寄存器有冲突,会丢失数据
//不知道有谁遇到过?知道为什么的?分享下?
temp= i*((temp&0xFFFFFF00)|(int(*(username+i-1))));
num +=temp;
}
return num;
}
int KeyGen(char * username)
{
int i;
int namelen;
char Rcode[22] = {0};
long num1 = 0,num2=0,num3=0,num4=0,num5=0;
long _EAX,_EBX,_ECX,_EDX;
Function f_1(ByVal s) Dim iLen iLen = Len(s) f_1 = Asc(s) * Asc(Mid(s, iLen, 1)) * Asc(Mid(s, iLen \ 2 + 1, 1)) End Function
Function f_2(ByVal s) Dim i, iLen, iResult, iEdx iLen = Len(s) iResult = 0 iEdx = 0 For i = iLen To 1 Step -1 iEdx = ((iEdx \ &H100) * &H100 + Asc(Mid(s, i, 1))) * i iResult = iResult + iEdx Next f_2 = iResult + iLen End Function
Sub GetCpuInfo(EBX, ECX, EDX) Dim s, oCPU For Each oCPU In GetObject("winmgmts:\\.\root\cimv2:Win32_Processor").instances_ s = oCPU.Manufacturer Exit For Next EBX = StrToInt(Left(s, 4)) EDX = StrToInt(Mid(s, 5, 4)) ECX = StrToInt(Right(s, 4)) End Sub
Function StrToInt(ByVal s) Dim i, iResult iResult = 0 For i = 1 To Len(s) iResult = iResult + Asc(Mid(s, i, 1)) * &H100 ^ (i - 1) Next StrToInt = iResult End Function
Function f_3(ByVal s) Dim i, iResult iResult = 0 For i = 1 To Len(s) iResult = iResult + Asc(Mid(s, i, 1)) Next f_3 = iResult End Function
Function iMul(ByVal iA, ByVal iB) Dim sA, sB, sResult Dim i, j, acc, n Dim aA(7), aB(7), arr(7, 7), aResult(7) sA = Right("00000000" & HexEx(iA), 8) sB = Right("00000000" & HexEx(iB), 8)
For i = 0 To 7 aA(i) = Eval("&H" & Mid(sA, 8 - i, 1)) aB(i) = Eval("&H" & Mid(sB, 8 - i, 1)) Next
For i = 0 To 7 For j = 0 To 7 arr(i, j) = 0 Next Next
For i = 0 To 7 acc = 0 For j = 0 To 7 If i + j > 7 Then Exit For n = aA(j) * aB(i) + acc arr(i, i + j) = n Mod &H10 acc = n \ &H10 Next Next
acc = 0 For i = 0 To 7 n = 0 For j = 0 To 7 n = n + arr(j, i) Next n = n + acc aResult(i) = Hex(n Mod &H10) acc = n \ &H10 Next
sResult = "" For i = 0 To 7 sResult = aResult(i) & sResult Next
iMul = CStr(Eval("&H" & Right(sResult, 7)) + Eval("&H" & Left(sResult, 1)) * 16 ^ 7) End Function
Function HexEx(ByVal iNum) Dim a(), i, s, sResult If iNum = 0 Then sResult = "0" Else s = "0123456789ABCDEF" i = -1 Do i = i + 1 ReDim Preserve a(i) If iNum < 1 Then a(i) = 0 Else a(i) = Split(CStr(iNum), ".")(0) iNum = iNum / 16 End If Loop Until a(i) = 0
sResult = "" For i = UBound(a) To 1 Step -1 sResult = sResult & Mid(s, a(i - 1) - a(i) * 16 + 1, 1) Next End If
HexEx = sResult End Function
Function f_4(ByVal n) f_4 = Chr(Eval("&H" & Right(Hex(n Mod &H1A + &H41), 2))) End Function
Function IntToStr(ByVal n) ' Dim i, sResult ' sResult = "" ' For i = 1 To 4 ' sResult = CStr(n Mod 10) & sResult ' n = n \ 10 ' Next ' IntToStr = sResult IntToStr = Right("0000" & CStr(n), 4) End Function