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

timeout - Handshake_timeout on RabbitMQ using python and pika from remote vm -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

c# - Search and Add Comment with OpenXML for Word -