Advertisement
ASP_Volume2 String Manipulation #37780

brute force algorithm

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

AI

AIサマリー: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

ソースコード
original-source
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
オリジナルのコメント (3)
Wayback Machineから復元