VB icon

brute force algorithm

Email
Submitted on: 1/29/2015 3:32:00 PM
By: Xeeky (from psc cd)  
Level: Intermediate
User Rating: By 2 Users
Compatibility: VB 4.0 (32-bit), VB 5.0, VB 6.0
Views: 623
 
     it's supposed to return the next password in a sequence of passwords, not random passwords, or a dictionary attack. it's designed to return case-insensitive alphanumeric passwords, but that can easily be changed, i can't help you do that, it's up to you
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
'**************************************
' Name: brute force algorithm
' Description:it's supposed to return the next password in a sequence of passwords, not random passwords, or a dictionary attack. it's designed to return case-insensitive alphanumeric passwords, but that can easily be changed, i can't help you do that, it's up to you
' By: Xeeky (from psc cd)
'
' Inputs:startPW - this is the pw you want the algorithm to start from
noChange - if this is True, it'll just poll for the next pw w/o changing it inside the function
startLength - ignored if startPW is used, must be > 1, it determines the length of the starting password.
'
' Returns:the next base35 string (alphanumeric, lowercase)
'
' Side Effects:none, as long as startLength is greater than 0
'**************************************

Public Function NextPW(Optional startPW As String, Optional noChange As Boolean, Optional startLength = 1) As String
Dim pw() As String, i As Long, s As Long
Static curPW As String
If startPW <> "" And curPW = "" Then
curPW = startPW
NextPW = curPW
Exit Function
End If
If curPW = "" Then
curPW = String(startLength, 48)
NextPW = curPW
Exit Function
End If
If curPW = String(Len(curPW), 122) Then
NextPW = String(Len(curPW) + 1, 48)
If noChange = False Then curPW = NextPW
Exit Function
End If
ReDim pw(Len(curPW))
For i = 1 To Len(curPW)
pw(i) = Mid(curPW, i, 1)
Next
i = UBound(pw)
donextchar:
s = Asc(pw(i)) + 1
Select Case s
Case 58
pw(i) = Chr(97)
Case 123
pw(i) = Chr(48)
i = i - 1
GoTo donextchar
Case Else
pw(i) = Chr(s)
End Select
For s = LBound(pw) To UBound(pw)
NextPW = NextPW & pw(s)
Next
If noChange = False Then curPW = NextPW
End Function


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.