Skip to content

Instantly share code, notes, and snippets.

Avatar
🤡
How about another joke, Murray?

Karim El-Husseiny kelhusseiny

🤡
How about another joke, Murray?
View GitHub Profile
View password_hashing_with_salt.rb
salt= Digest::SHA1.hexdigest("# We add {email} as unique value and #{Time.now} as random value")
encrypted_password= Digest::SHA1.hexdigest("Adding #{salt} to {password}")
View password_hashing.rb
require 'digest/sha1'
encrypted_password= Digest::SHA1.hexdigest(password)
View users_controller.rb
before_filter :save_login_state, :only => [:new, :create]
View routes.rb
match ':controller(/:action(/:id))(.:format)'
View Gemfile
gem 'bcrypt-ruby', :require => 'bcrypt'
View users_controller.rb
class UsersController < ApplicationController
def new
@user = User.new
end
def create
@user = User.new(params[:user])
if @user.save
flash[:notice] = "You signed up successfully"
flash[:color]= "valid"
else
View password_encryption_with_BCrypt.rb
salt = BCrypt::Engine.generate_salt
encrypted_password = BCrypt::Engine.hash_secret(password, salt)