Skip to content

Instantly share code, notes, and snippets.

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 #{} 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 =
def create
@user =[:user])
flash[:notice] = "You signed up successfully"
flash[:color]= "valid"
View password_encryption_with_BCrypt.rb
salt = BCrypt::Engine.generate_salt
encrypted_password = BCrypt::Engine.hash_secret(password, salt)