【已解决】帮忙把VB代码转换为Au3
本帖最后由 KLU3K 于 2010-7-6 12:38 编辑下面的代码能转换成au3的么?
这段代码是网通用户名转换的代码。看不懂,能否帮忙转换一下?
Function EncodeUser(UserName As String) As String
If CheckUserEncode.Value Then
Dim outstr As String
Dim DicStr As String
DicStr = "9012345678abcdeABCDEFGHIJKLMNfghijklmnUVWXYZxyzuvwopqrstOPQRST"
Dim DicA() As String
ReDim DicA(Len(DicStr) - 1)
Dim ff As Long
For ff = 0 To Len(DicStr) - 1
DicA(ff) = Mid(DicStr, ff + 1, 1)
Next
Dim DicB(15) As Byte
DicB(0) = &H11
DicB(1) = &H34
DicB(2) = &HC9
DicB(3) = &H23
DicB(4) = &H75
DicB(5) = &H18
DicB(6) = &HD7
DicB(7) = &HE2
DicB(8) = &H12
DicB(9) = &H35
DicB(10) = &H29
DicB(11) = &H2B
DicB(12) = &HEC
DicB(13) = &HB6
DicB(14) = &H23
DicB(15) = &H19
Dim inputstr As String
inputstr = UserName
Dim InputStrArray() As String
ReDim InputStrArray(Len(inputstr) - 1)
Dim OutPutArray() As String
ReDim OutPutArray(500)
For ff = 0 To Len(inputstr) - 1
InputStrArray(ff) = Mid(inputstr, ff + 1, 1)
Next
Dim i As Long i = 0
Dim j As Long j = 0
Dim num4 As Long: num4 = &H25
Dim di As Long
Dim var2 As Long
Dim index As Long
Dim var3 As Long: var3 = 0
For i = 0 To Len(inputstr) - 1
For j = 0 To Len(DicStr) - 1
If InputStrArray(i) = DicA(j) Then
If i >= &H10 Then
di = DicB(i Mod &H10)
Else
di = DicB(i)
End If
var2 = num4 * 3
index = (((di Xor var2) Xor var3) + j) Mod &H3E
OutPutArray(i) = DicA(index)
var2 = index
num4 = num4 Xor (var2 + &H24D9)
End If
Next j
If OutPutArray(i) = "" Then
OutPutArray(i) = InputStrArray(i)
End If
var3 = var3 + 5
Next i
Dim kk As Long
For kk = 0 To UBound(OutPutArray)
If OutPutArray(kk) <> "" Then
outstr = outstr + OutPutArray(kk)
End If
Next
outstr = "1:" + outstr
EncodeUser = outstr
Else
EncodeUser = UserName
End If
End Function
帮忙转换的我给加分 转好了。MsgBox(0,"",EncodeUser("13213asdf12",True))
;函数计算号码 (参数 用户名, 参数 是否算号 算号为真 不算为假)
Func EncodeUser($UserName,$IsCreateCode=False)
;如果是要算号,则开始算号,否则返回用户名。
Local $EncodeUser="";定义结果字符串
If $IsCreateCode=True Then
;定义变量 输出字符串 字典字符串
Local $OutStr="",$DicStr="9012345678abcdeABCDEFGHIJKLMNfghijklmnUVWXYZxyzuvwopqrstOPQRST"
; 输入字符串等于用户名 这几个是干什么的?
Local $InputStr=$UserName , $Num4=0x25,$var3 = 0 , $di , $var2 , $index
; 字典数组 输入字符数组 输出字符数组 字典数组2
Local $DicArray,$InputStrArray,$OutPutArray,$DicB
;字典数组2赋值。
$DicB = 0X11
$DicB = 0X34
$DicB = 0XC9
$DicB = 0X23
$DicB = 0X75
$DicB = 0X18
$DicB = 0XD7
$DicB = 0XE2
$DicB = 0X12
$DicB = 0X35
$DicB = 0X29
$DicB = 0X2B
$DicB = 0XEC
$DicB = 0XB6
$DicB = 0X23
$DicB = 0X19
;将字典字符串按位拆分到字典数组中去。
For $ff = 0 To StringLen($DicStr) - 1 Step 1
$DicArray[$ff] = StringMid($DicStr, $ff + 1, 1)
Next
;将输入字符串(用户名) 按位拆分到输入数组中去。
For $ff=0 To StringLen($InputStr)-1 Step 1
$InputStrArray[$ff]=StringMid($InputStr,$ff+1,1)
Next
;开始算号。具体算法我没有分析。
For $i = 0 To StringLen($inputstr) - 1 Step 1
For $j = 0 To StringLen($DicStr) - 1 Step 1
If $InputStrArray[$i] = $DicArray[$j] Then
If $i >= 0x10 Then
$di = $DicB
Else
$di = $DicB[$i]
EndIf
$var2 = $num4 * 3
$index = Mod((BitXOR(BitXOR($di,$var2),$var3) + $j),0x3E )
$OutPutArray[$i] = $DicArray[$index]
$var2 = $index
$num4 = BitXOR($num4,($var2+0x24D9))
EndIf
Next
If $OutPutArray[$i] = "" Then
$OutPutArray[$i] = $InputStrArray[$i]
EndIf
$var3 = $var3 + 5
Next
;算出的号存在输出数组中。 这个FOR循环是将输出数组中的所有元素组合成一个字符串。
For $kk = 0 To UBound($OutPutArray)-1
If $OutPutArray[$kk] <> "" Then
$outstr = $outstr&$OutPutArray[$kk]
EndIf
Next
;输出字符串前加上1:这2个字符
$outstr = "1:"&$outstr
$EncodeUser = $outstr
Else
$EncodeUser = $UserName
EndIf
Return $EncodeUser
EndFunc 非常感谢楼上的!
页:
[1]