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;
注册机用excel的vbe来写:
由于有溢出才多写两个函数:
Function iPlus(Num1 As String, Num2 As String) As String
'200位数以下正整数加法
Dim l(1 To 2) As Integer, Piece(1 To 50, 1 To 2) As String, j As Integer
Dim k As Integer, k2 As String, i As Integer, s1 As Integer, s2 As Integer
Randomize
If Len(Num1) Mod 4 = 0 Then
l(1) = Len(Num1) / 4
Else
l(1) = Len(Num1) \ 4 + 1
End If
If Len(Num2) Mod 4 = 0 Then
l(2) = Len(Num2) / 4
Else
l(2) = Len(Num2) \ 4 + 1
End If
For j = 1 To l(1)
s1 = j * 4 - 1
s2 = Len(Num1) - s1
If s2 <= 0 Then
s2 = s2 + 3
s1 = Len(Num1) - 1
Else
s2 = 4
End If
Piece(j, 1) = Mid(Num1, Len(Num1) - s1, s2)
Next
For j = 1 To l(2)
s1 = j * 4 - 1
s2 = Len(Num2) - s1
If s2 <= 0 Then
s2 = s2 + 3
s1 = Len(Num2) - 1
Else
s2 = 4
End If
Piece(j, 2) = Mid(Num2, Len(Num2) - s1, s2)
Next
j = 1: k = 0: S = ""
Do While Piece(j, 1) <> "" Or Piece(j, 2) <> ""
k = Val(Piece(j, 1)) + Val(Piece(j, 2))
k2 = CStr(k)
If k > 9999 Then
k2 = Mid(k2, 2, 4)
i = Val(Piece(j + 1, 1)) + 1
Piece(j + 1, 1) = CStr(i)
ElseIf k < 1000 Then
If k > 99 Then
k2 = "0" & k2
ElseIf k < 100 Then
If k > 9 Then
k2 = "00" & k2
Else
k2 = "000" & k2
End If
End If
End If
S = k2 & S
j = j + 1
Loop
Do While Left(S, 1) = 0
S = Mid(S, 2, 254)
Loop
iPlus = S
End Function
Function IMult(Number1 As String, Number2 As String) As String
'高精度乘法
Dim Ans() As Byte, s1() As Byte, s2() As Byte, Temp As Byte, Zero As Boolean
Dim l1 As Integer, l2 As Integer
Dim i As Integer, j As Integer, S As String
l1 = Len(Number1)
l2 = Len(Number2)
ReDim s1(l1 - 1)
ReDim s2(l2 - 1)
ReDim Ans(l1 + l2 - 1)
'入
For i = 0 To IIf(l1 > l2, l1 - 1, l2 - 1)
If i < l1 Then s1(i) = Mid(Number1, l1 - i, 1)
If i < l2 Then s2(i) = Mid(Number2, l2 - i, 1)
Next
'算
For i = 0 To l1 - 1
For j = 0 To l2 - 1
Temp = s1(i) * s2(j) + Temp
Ans(i + j) = Ans(i + j) + Temp Mod 10
If Ans(i + j) >= 10 Then Temp = Temp + 10: Ans(i + j) = Ans(i + j) Mod 10
Temp = Temp \ 10
Next
If Temp > 0 Then Ans(i + j) = Temp: Temp = 0
Next
If Temp > 0 Then Ans(l1 + l2 - 1) = Temp
'出
S = ""
Zero = True
For i = 0 To l1 + l2 - 1
If Zero = True Then
If Ans(l1 + l2 - 1 - i) > 0 Then Zero = False: S = S & Ans(l1 + l2 - 1 - i)
Else
S = S & Ans(l1 + l2 - 1 - i)
End If
Next
IMult = S
End Function
Private Sub CommandButton4_Click()
Dim S, s1 As String, i, j, l, al As Integer
Dim a, c As String
s1 = ""
S = Sheet1.Cells(5, 2)
l = Len(S)
c = 4294967295# / ((Asc(Mid$(S, 1, 1)) Mod Asc(Mid$(S, 2, 1))) * Asc(Mid$(S, 3, 1)) + 1)
For i = 0 To 14
a = CDec(iPlus(IMult(c, "214013"), "2531011"))
c = a - 4294967296# * Int(a / 4294967296#)
a1 = CInt(Int(c / 65536) And 32767)
Next i
For i = 1 To l
al = Asc(Mid$(S, 1, 1))
al = (al \ 32) * 123
If al <> 0 Then
For x = 1 To al
a = CDec(iPlus(IMult(c, "214013"), "2531011"))
c = a - 4294967296# * Int(a / 4294967296#)
a1 = CInt(Int(c / 65536) And 32767)
Next x
End If
a = CDec(iPlus(IMult(c, "214013"), "2531011"))
c = a - 4294967296# * Int(a / 4294967296#)
a1 = CInt(Int(c / 65536) And 32767)
s1 = s1 & Chr((a1 Mod 26) + 65)
Next i
Sheet1.Cells(5, 3) = s1
End Sub