by macsux (1 Submission)
Category: String Manipulation
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Wed 24th October 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Generates variations of the string based on the brute force tactic.
Private Function bf(CharSet As String, pwd As String)
Dim sLastChar As String
Dim i As Integer
sLastChar = Right(pwd, 1)
If String(Len(pwd), Right(CharSet, 1)) = pwd Then
bf = String(Len(pwd) + 1, Left(CharSet, 1))
Else
If sLastChar = Right(CharSet, 1) Then
bf = bf(CharSet, Left(pwd, Len(pwd) - 1)) & Left(CharSet, 1)
Else
For i = 1 To Len(CharSet)
If sLastChar = Mid(CharSet, i, 1) Then
sLastChar = Mid(CharSet, i + 1, 1)
Exit For
End If
Next
bf = Left(pwd, Len(pwd) - 1) & sLastChar
End If
End If
End Function
'This little peice of code I just wrote to demonstrate how it works. It will fill listbox with variations, starting with "A","B","C","AA","AB", etc. You get the point.
Private Sub Command2_Click()
Dim pwd As String
pwd = "A"
Do Until pwd = "AAAA"
Me.List1.AddItem pwd
pwd = (bf("ABC", pwd))
Loop
Me.List1.AddItem pwd
End Sub
No comments have been posted about Generates variations of the string based on the brute force tactic.. Why not be the first to post a comment about Generates variations of the string based on the brute force tactic..