git ssb

0+

dangerousbeans / %aPBe2k3ugtjBr4rrsU1…



Commit 8445c8f85076cf66f2507962a35e0f5af49ab4a9

raise an exception if the cost is greater than 31. fixes #27

Aaron Patterson committed on 9/12/2011, 8:17:59 PM
Parent: 045a495f0b2cd504dd5ffe860bab976bb1272017

Files changed

CHANGELOGchanged
Gemfile.lockchanged
lib/bcrypt.rbchanged
spec/bcrypt/password_spec.rbchanged
CHANGELOGView
@@ -41,4 +41,7 @@
4141
4242 3.0.0 Aug 24, 2011
4343 - Bcrypt C implementation replaced with a public domain implementation.
4444 - License changed to MIT
45+
46+3.0.1
47+ - create raises an exception if the cost is higher than 31. GH #27
Gemfile.lockView
@@ -1,8 +1,8 @@
11 PATH
22 remote: .
33 specs:
4- bcrypt-ruby (2.1.4)
4+ bcrypt-ruby (3.0.0)
55
66 GEM
77 remote: http://rubygems.org/
88 specs:
lib/bcrypt.rbView
@@ -156,8 +156,9 @@
156156 # Example:
157157 #
158158 # @password = BCrypt::Password.create("my secret", :cost => 13)
159159 def create(secret, options = { :cost => BCrypt::Engine::DEFAULT_COST })
160+ raise ArgumentError if options[:cost] > 31
160161 Password.new(BCrypt::Engine.hash_secret(secret, BCrypt::Engine.generate_salt(options[:cost]), options[:cost]))
161162 end
162163 end
163164
spec/bcrypt/password_spec.rbView
@@ -33,8 +33,14 @@
3333 @secret = "U*U"
3434 @hash = "$2a$05$CCCCCCCCCCCCCCCCCCCCC.E5YPO9kmyuRGyh0XouQYb4YMJKvyOeW"
3535 end
3636
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+
3743 specify "should read the version, cost, salt, and hash" do
3844 password = BCrypt::Password.new(@hash)
3945 password.version.should eql("2a")
4046 password.cost.should equal(5)

Built with git-ssb-web