Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

  • Loading branch information...
commit 8445c8f85076cf66f2507962a35e0f5af49ab4a9 1 parent 045a495
@tenderlove tenderlove authored
View
3  CHANGELOG
@@ -42,3 +42,6 @@
3.0.0 Aug 24, 2011
- Bcrypt C implementation replaced with a public domain implementation.
- License changed to MIT
+
+3.0.1
+ - create raises an exception if the cost is higher than 31. GH #27
View
2  Gemfile.lock
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
- bcrypt-ruby (2.1.4)
+ bcrypt-ruby (3.0.0)
GEM
remote: http://rubygems.org/
View
1  lib/bcrypt.rb
@@ -157,6 +157,7 @@ class << self
#
# @password = BCrypt::Password.create("my secret", :cost => 13)
def create(secret, options = { :cost => BCrypt::Engine::DEFAULT_COST })
+ raise ArgumentError if options[:cost] > 31
Password.new(BCrypt::Engine.hash_secret(secret, BCrypt::Engine.generate_salt(options[:cost]), options[:cost]))
end
end
View
6 spec/bcrypt/password_spec.rb
@@ -34,6 +34,12 @@
@hash = "$2a$05$CCCCCCCCCCCCCCCCCCCCC.E5YPO9kmyuRGyh0XouQYb4YMJKvyOeW"
end
+ specify "the cost is too damn high" do
+ lambda {
+ BCrypt::Password.create("hello", :cost => 32)
+ }.should raise_error(ArgumentError)
+ end
+
specify "should read the version, cost, salt, and hash" do
password = BCrypt::Password.new(@hash)
password.version.should eql("2a")
Please sign in to comment.
Something went wrong with that request. Please try again.