Created
July 16, 2011 03:20
-
-
Save cormacrelf/1085964 to your computer and use it in GitHub Desktop.
Ruby Password Practise
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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