class Hello::Encryptors::Complex
Public Class Methods
new(cost=nil)
click to toggle source
# File lib/hello/encryptors/complex.rb, line 4 def initialize(cost=nil) require 'bcrypt' cost ||= Rails.env.test? ? 1 : 10 BCrypt::Engine.cost = cost rescue LoadError s = "your Gemfile needs: gem 'bcrypt'" puts [s.red, s.yellow, s.green] raise end
Public Instance Methods
encrypt(string)
click to toggle source
# File lib/hello/encryptors/complex.rb, line 14 def encrypt(string) BCrypt::Password.create(string).to_s end
match(string, digest)
click to toggle source
# File lib/hello/encryptors/complex.rb, line 18 def match(string, digest) BCrypt::Password.new(digest) == string rescue BCrypt::Errors::InvalidHash false end