Sha256: fa5833a3720d7293af4371ddcdf64b4d22364c0e27b6c81662529d0a56a19c59

Contents?: true

Size: 575 Bytes

Versions: 3

Compression:

Stored size: 575 Bytes

Contents

require "digest/sha2"

module Shield
  module Password
    autoload :Simple, "shield/password/simple"
    autoload :PBKDF2, "shield/password/pbkdf2"

    def self.strategy=(s)
      @strategy = s
    end

    def self.strategy
      @strategy ||= Shield::Password::Simple
    end

    def self.encrypt(password, salt = generate_salt)
      strategy.encrypt(password, salt)
    end

    def self.check(password, encrypted)
      strategy.check(password, encrypted)
    end

    def self.generate_salt
      Digest::SHA512.hexdigest(Time.now.to_f.to_s)[0, 64]
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
shield-0.1.0 lib/shield/password.rb
shield-0.1.0.rc1 lib/shield/password.rb
shield-0.0.4 lib/shield/password.rb