Skip to content

Instantly share code, notes, and snippets.

@joequery
Created May 11, 2012 15:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joequery/2660518 to your computer and use it in GitHub Desktop.
Save joequery/2660518 to your computer and use it in GitHub Desktop.
How long to brute force a key of length n?
# How long to brute force keys
ks = 1000000000 # A billion keys per second
clusters = 10 # How many computers in the cluster attacking our key?
numChars = 38 # We have 38 characters available to use in the key
n = 100 # Length of the key string
combinations = numChars ** n # This ignores variable length too
# How many years it would take a single computer to brute force.
secondsInYear = 31556926
singleCrackTimeInYears = (1.0 * combinations) / ks / secondsInYear
totalCrackTime = singleCrackTimeInYears / clusters
puts "#{totalCrackTime} years"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment