title: How To Speed Up My Brute Force Attack
body: <p>So I have a brute force attacker, and I wanted to see how long it would take to crack my password. However, when I went to a couple of sites like <a href="https://www.betterbuys.com/estimating-password-cracking-times/" rel="nofollow noreferrer">this</a> that estimate your length or places that calculate how long it would take like this one <a href="https://howsecureismypassword.net/" rel="nofollow noreferrer">here</a>, they all say that a six-seven digit password could be cracked in under a second!</p>
  
  <p>How can I speed up my brute force program to match speeds like these?</p>
  
  <pre><code># Imports
  import itertools
  import time
  
  
  # Brute force function
  def tryPassword(passwordSet, stringTypeSet):
      start = time.time()
      chars = stringTypeSet
      attempts = 0
      for i in range(1, 9):
          for letter in itertools.product(chars, repeat=i):
              attempts += 1
              letter = ''.join(letter)
              if letter == passwordSet:
                  end = time.time()
                  distance = end - start
                  return (attempts, distance)
  
  
  password = "123456"
  # Allowed characters
  stringType = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`~!@#$%^&amp;*()_-+=[{]}|:;'\",&lt;.&gt;/?"
  tries, timeAmount = tryPassword(password, stringType)
  print("CyanCoding's BFPC cracked the password %s in %s tries and %s seconds!" % (password, tries, timeAmount)))
  </code></pre>