BCrypt Example

# how does bcrypt work under the surface?

require 'bcrypt'
# our password is turkey dinner
# it needs some salt to give flavour
salt = BCrypt::Engine.generate_salt
p salt

pwd = 'hooloovoo42'
# bcrypt combines salt + password
combined_password = pwd + salt
p combined_password

# we encrypt our password as a hash
# hash_secret does the above!
# hash_secret makes our combined password
# and generates a hash for us
hash = BCrypt::Engine.hash_secret(pwd, salt)
p hash

#login
# first off, you need the user's salt
# save it to db, cookie, etc
# may need to have a way to reset
# usr passes in their password

## users_entry = params[:password]
# compare hash in db
# compare results
# look in postm /login: https://github.com/ga-chicago/sinatra_crud/blob/master/controllers/UsersController.rb

results matching ""

    No results matching ""