Skip to content

Instantly share code, notes, and snippets.

@cormacrelf
Created July 16, 2011 03:20
Show Gist options
  • Save cormacrelf/1085964 to your computer and use it in GitHub Desktop.
Save cormacrelf/1085964 to your computer and use it in GitHub Desktop.
Ruby Password Practise
# Ruby Password Practise Utility
#!/usr/local/bin/ruby
require 'rubygems'
require 'highline/import'
$password = ask("Enter your password: ") { |q| q.echo = "*" }
puts "Now type your password and hit return."
$success = 0
def check(possible)
if possible == $password
print " # Yes!\n"
$success += 1
else
print " # No! Wrong!\n"
end
end
def get_check
possible = ask("> ") { |q| q.echo = "*" }
check(possible)
end
10.times do
get_check()
end
puts "Done. You got #{$success}/10 right."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment