Sha256: 3ff2441d4d3a6639ecffd6c210416e8e0aaf034434d01d185bcae1085b397c0e

Contents?: true

Size: 444 Bytes

Versions: 3

Compression:

Stored size: 444 Bytes

Contents

module Shield
  module Password
    module Simple
      extend self

      def encrypt(password, salt)
        digest(password, salt) + salt
      end

      def check(password, encrypted)
        sha512, salt = encrypted.to_s[0..127], encrypted.to_s[128..-1]

        digest(password, salt) == sha512
      end

    private
      def digest(password, salt)
        Digest::SHA512.hexdigest("#{ password }#{ salt }")
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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