Browse files

Now using EzCrypto library instead of crypt/blowfish.

  • Loading branch information...
1 parent a4db9ac commit c42287c428af0ab1007ae22c5e0156a02f201e91 @skalnik committed Sep 24, 2008
Showing with 18 additions and 11 deletions.
  1. +10 −7 bin/lawn
  2. +8 −4 lib/lawn.rb
View
17 bin/lawn
@@ -1,6 +1,6 @@
#!/usr/bin/ruby
require 'rubygems'
-require 'crypt/blowfish'
+require 'ezcrypto'
require 'optparse'
require 'yaml'
require '../lib/lawn'
@@ -29,19 +29,22 @@ if !File.exists?(file) or options[:setup] # First run or rerun setup.
File.open(file, 'w') { |f|
f.write(YAML::dump(info))
}
- puts "OK. Lawn-login is now setup. To login next time, run `lawn`"
- exit
+ puts "OK. Lawn-login is now setup, now attempting to login for the first time. To login next time, run `lawn`."
else # File exists, so lets get the info from there!
info = YAML.load_file(file)
end
if options[:password]
+ puts info[:encrypted_password]
print "New LAWN password? "
- info[:encrypted_password] = Lawn.encrypt_password(Lawn.get_encryption_password(info[:username]), gets.chomp)
+ puts info[:encrypted_password] = Lawn.encrypt_password(Lawn::get_encryption_password(info[:username]), gets.chomp)
+
+ File.open(file, 'w') { |f|
+ f.write(YAML::dump(info))
+ }
end
-blowfish = Crypt::Blowfish.new(Lawn.get_encryption_password(info[:username]))
-PASSWORD = blowfish.decrypt_block(info[:encrypted_password])
-USERNAME = info[:username]
+PASSWORD = Lawn.decrypt_password(Lawn.get_encryption_password(info[:username]), info[:encrypted_password])
+USERNAME = info[:username]
puts `curl -s -f -F username=\'#{USERNAME}\' -F password=\'#{PASSWORD}\' -F iss=\'false\' -F output=\'text\' https://auth.lawn.gatech.edu/index.php`
View
12 lib/lawn.rb
@@ -1,7 +1,8 @@
-require 'crypt/blowfish'
+require 'rubygems'
+require 'ezcrypto'
module Lawn
extend self
- VERSION = "0.0.4"
+ VERSION = "0.0.5"
def get_encryption_password(username)
if username.length < 7
@@ -12,7 +13,10 @@ def get_encryption_password(username)
end
def encrypt_password(encryption_password, password)
- blowfish = Crypt::Blowfish.new(encryption_password)
- blowfish.encrypt_block(password)
+ EzCrypto::Key.encrypt_with_password encryption_password, "salt", password
+ end
+
+ def decrypt_password(encryption_password, password)
+ EzCrypto::Key.decrypt_with_password encryption_password, "salt", password
end
end

0 comments on commit c42287c

Please sign in to comment.