Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Cracker
- attr_accessor :current
- OPTS = [('a'..'z'),('A'..'Z'),('0'..'9')].map{|n| n.to_a }.flatten
- def initialize(pass)
- @current = OPTS.first
- crack while @current != pass
- puts "Password is #{@current}"
- end
- def crack
- current_array = @current.split(//)
- if current_array.all? {|o| o == OPTS.last}
- current_array = [OPTS.first]*(current_array.length+1)
- else
- poped = []
- poped << current_array.pop while current_array.last == OPTS.last
- last = current_array.pop
- current_array.push OPTS[OPTS.index(last)+1]
- current_array += ([OPTS.first]*poped.length)
- end
- @current = current_array.join
- end
- end
Add Comment
Please, Sign In to add comment