Query the "Password Poor Lift Algorithm" in Google, you can get about 5,000 results, provide an algorithm instance of C. This article does not want to copy these instance code again, if the brothers needed can be searched on Google. After studying these code, I feel that recursion can be used to enhance the performance of the algorithm.
The tightness, I am like the C code, I can understand a little, but I don't slip. One sentence, half tonar. So this article uses VB.NET language, I hope everyone can understand. VB, better understand.
Below is provided with two codes, using the same statement.
Friend Delegate Sub Callback (Byval Password AS String) 'Password Output Press
Private Const PStartLen As Integer = 1 Private Const PMaxLen As Integer = 6 'generates the maximum password length Private PDict () As Char = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" .ToCharArray' password Dictionary
The first paragraph is a VB.NET version of C code:
'翻 版
Friend Sub Makepass_General (Byval CNN As Callback) DIM PDICTLEN As long = len (PDICT) Get Cryptography Dictionary DIM CPASS (PMaxlen - 1) AS String 'Send Generated Password DIM PLEN AS INTEGER
For plen = pstartlen to pmaxlen 'password length DIM array (pmaxlen - 1) AS integer' password dictionary Dim Bnext as boolean = true
While Bnext Dim i, J AS Integer
For i = 0 to Plen - 1 CPass (i) = pdict (array (i)) Next
Cnn.invoke (String.Join (", CPASS)) 'Password Output
For J = Plen - 1 TO 0 Step -1 'Password Pointer ARRAY (J) = 1
IF array (j) 'Recursion method password poor algorithm Friend Sub makepass_recursion (Byval CNN As Callback) DIM PLEN AS INTEGER for Plen = PStartlen TO PMAXLEN' Password length DIM CPASS (Plen - 1) AS String 'Clear MakePass_Recursion (Cnn, CPass) Next End Sub Private Sub MakePass_Recursion (ByVal Cnn As CallBack, ByRef CPass () As String, Optional ByVal ID As Integer = 0) Dim i As Integer For i = 0 To PDict.Length - 1 CPass (ID ) = Pdict (i) IF id = cpass.length - 1 Then cnn.invoke (String.join (", CPASS)) 'Password Output Else Makepass_recursion (CNN, CPass, ID 1) end if Next end SUB The code is very simple, don't do it. The two-segment code was tested, and the password poor algorithm after the recursive method was optimized, and it increased by approximately 1 times higher than the conventional algorithm. The class door ax, let the masters laugh. Please advise.