ruby on rails - want to encrypt password like devise gem and check in db -


how encrypt password through devise gem manually? there gem this?

password coming form web service , want encrypt , check in db

devise internally uses bcrypt gem encryption. bcrypt

class user < activerecord::base     before_save :encrypt_password   validates_confirmation_of :password   validates_presence_of :password, :on => :create    def encrypt_password     if password.present?       self.password_salt = bcrypt::engine.generate_salt       self.password_hash = bcrypt::engine.hash_secret(password,password_salt)     end   end end 

try this.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -