Skip to content

Instantly share code, notes, and snippets.

@dillonhafer
Created August 28, 2014 02:10
Show Gist options
  • Save dillonhafer/9ded6436faa1fbfc058a to your computer and use it in GitHub Desktop.
Save dillonhafer/9ded6436faa1fbfc058a to your computer and use it in GitHub Desktop.
Get random passwords from GRC
require 'nokogiri'
require 'open-uri'
class Grc
attr_accessor :hex, :ascii, :alpha
PAGE_URL = "https://www.grc.com/passwords.htm"
def initialize
chars = fetch
@hex = chars[0].text
@ascii = chars[1].text
@alpha = chars[2].text
end
def self.random(complexity)
self.new.send(complexity.to_s)
end
private
def fetch
Nokogiri::HTML(open(PAGE_URL)).css("font[size='2']")[1..3]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment