Commit 8445c8f85076cf66f2507962a35e0f5af49ab4a9
raise an exception if the cost is greater than 31. fixes #27
Aaron Patterson committed on 9/12/2011, 8:17:59 PMParent: 045a495f0b2cd504dd5ffe860bab976bb1272017
Files changed
CHANGELOG | changed |
Gemfile.lock | changed |
lib/bcrypt.rb | changed |
spec/bcrypt/password_spec.rb | changed |
CHANGELOG | ||
---|---|---|
@@ -41,4 +41,7 @@ | ||
41 | 41 | |
42 | 42 | 3.0.0 Aug 24, 2011 |
43 | 43 | - Bcrypt C implementation replaced with a public domain implementation. |
44 | 44 | - License changed to MIT |
45 | + | |
46 | +3.0.1 | |
47 | + - create raises an exception if the cost is higher than 31. GH #27 |
Gemfile.lock | ||
---|---|---|
@@ -1,8 +1,8 @@ | ||
1 | 1 | PATH |
2 | 2 | remote: . |
3 | 3 | specs: |
4 | - bcrypt-ruby (2.1.4) | |
4 | + bcrypt-ruby (3.0.0) | |
5 | 5 | |
6 | 6 | GEM |
7 | 7 | remote: http://rubygems.org/ |
8 | 8 | specs: |
lib/bcrypt.rb | ||
---|---|---|
@@ -156,8 +156,9 @@ | ||
156 | 156 | # Example: |
157 | 157 | # |
158 | 158 | # @password = BCrypt::Password.create("my secret", :cost => 13) |
159 | 159 | def create(secret, options = { :cost => BCrypt::Engine::DEFAULT_COST }) |
160 | + raise ArgumentError if options[:cost] > 31 | |
160 | 161 | Password.new(BCrypt::Engine.hash_secret(secret, BCrypt::Engine.generate_salt(options[:cost]), options[:cost])) |
161 | 162 | end |
162 | 163 | end |
163 | 164 |
spec/bcrypt/password_spec.rb | ||
---|---|---|
@@ -33,8 +33,14 @@ | ||
33 | 33 | @secret = "U*U" |
34 | 34 | @hash = "$2a$05$CCCCCCCCCCCCCCCCCCCCC.E5YPO9kmyuRGyh0XouQYb4YMJKvyOeW" |
35 | 35 | end |
36 | 36 | |
37 | + specify "the cost is too damn high" do | |
38 | + lambda { | |
39 | + BCrypt::Password.create("hello", :cost => 32) | |
40 | + }.should raise_error(ArgumentError) | |
41 | + end | |
42 | + | |
37 | 43 | specify "should read the version, cost, salt, and hash" do |
38 | 44 | password = BCrypt::Password.new(@hash) |
39 | 45 | password.version.should eql("2a") |
40 | 46 | password.cost.should equal(5) |
Built with git-ssb-web