;看意思 好象是求 密码暴力破解的组合算法啊!
Global $g_StringChar[3][2] = [[48, 57],[65, 90],[97, 122]]
; Example :
Global $g_Return = _CompesiteArray("2", 3), $g_Temp
For $g_I = 0 To UBound($g_Return)-1
$g_Temp = $g_Return[$g_I]
For $g_J = 1 To $g_Temp[0]
ConsoleWrite($g_Temp[$g_J] & " ")
Next
ConsoleWrite(@CRLF)
Next
; $s_Length = 长度
; $s_Flags = 1 数字
; 2 大写字母
; 4 小写字母
Func _CompesiteArray($s_Length = Default, $s_Flags = Default)
Local $s_Error = 0, $s_Return = "", $s_KeyWord
If $s_Length = Default Or StringLen($s_Length) = 0 Or Number($s_Length) = 0 Then
_ErrorReport("$s_Length", "Wrong Format")
$s_Error += 1
Else
$s_Length = Number($s_Length)
EndIf
If $s_Flags = Default Or StringLen($s_Flags) = 0 Or Number($s_Flags) = 0 Then
_ErrorReport("$s_Flags", "Wrong $s_Flags Param")
$s_Error += 2
EndIf
If Not $s_Error Then
For $s_I = 0 To 2
If BitAND($s_Flags, 2^$s_I) Then
_CreateKeyWord($s_KeyWord, $s_I)
EndIf
Next
If StringLen($s_KeyWord) = 0 Then
_ErrorReport("$s_Flags", "Not Include $s_Flags : 1 2 or 4")
$s_Error += 4
EndIf
EndIf
If Not $s_Error Then
Local $s_Temp[$s_Length]
For $s_I = 0 To $s_Length-1
$s_Temp[$s_I] = _CreateArray($s_KeyWord, $s_I+1)
Next
$s_Return = $s_Temp
EndIf
Return SetError($s_Error, 0, $s_Return)
EndFunc
Func _CreateKeyWord(ByRef $s_KeyWord, $s_Flags)
For $s_I = $g_StringChar[$s_Flags][0] To $g_StringChar[$s_Flags][1]
$s_KeyWord &= Chr($s_I)
Next
EndFunc
Func _CreateArray($s_KeyWord, $s_Length)
$s_KeyWord = StringSplit($s_KeyWord, "", 2)
Local $s_Return[1] = [0], $s_Counter[$s_Length], $s_Valve = 1, $s_Dimension = UBound($s_KeyWord)
While $s_Valve
For $s_I = $s_Length-1 To 1 Step -1
If $s_Counter[$s_I] = $s_Dimension Then
$s_Counter[$s_I-1] += 1
$s_Counter[$s_I] = 0
EndIf
Next
If $s_Counter[0] = $s_Dimension Then
$s_Valve = 0
Else
$s_Return[0] += 1
ReDim $s_Return[$s_Return[0]+1]
$s_Return[$s_Return[0]] = _CreateString($s_Counter, $s_KeyWord)
EndIf
$s_Counter[$s_Length-1] += 1
WEnd
Return $s_Return
EndFunc
Func _CreateString($s_Array, $s_KeyWord)
Local $s_Return
For $s_I = 0 To UBound($s_Array) - 1
$s_Return &= $s_KeyWord[$s_Array[$s_I]]
Next
Return $s_Return
EndFunc
Func _ErrorReport($s_Error, $s_Report)
ConsoleWrite("! ErrorReport : " & $s_Error & " (" & $s_Report & ") !" & @CRLF)
EndFunc
|