diff --git a/lib/bcrypt/engine.rb b/lib/bcrypt/engine.rb index 1a253b3..eb45c68 100644 --- a/lib/bcrypt/engine.rb +++ b/lib/bcrypt/engine.rb @@ -80,7 +80,9 @@ def self.hash_secret(secret, salt, _ = nil) # Generates a random salt with a given computational cost. def self.generate_salt(cost = self.cost) cost = cost.to_i - if cost > 0 + if cost > MAX_COST + raise Errors::InvalidCost.new("cost must be <= #{MAX_COST}") + elsif cost > 0 if cost < MIN_COST cost = MIN_COST end