Created
January 5, 2017 17:07
-
-
Save kenrett/d7209b691666cd1a89118c9853da35ac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module MCrypt | |
class Password | |
def initialize(hashed_password) | |
@hash = hashed_password | |
end | |
def self.create(plain_text_password) | |
plain_text_password | |
.reverse | |
.split(//) * "*" | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# require_relative './mcrypt' | |
class User < ActiveRecord::Base | |
# attr_writer :password | |
include BCrypt | |
# include MCrypt | |
def password | |
@password ||= Password.new(password_hash) | |
p @password | |
end | |
def password=(new_password) | |
@password = Password.create(new_password) | |
self.password_hash = @password | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment