Sha256: d93761e99c8731dbff678942cdf7eefe752e2c692eb8842284c64918f2ad3dd4

Contents?: true

Size: 512 Bytes

Versions: 1

Compression:

Stored size: 512 Bytes

Contents

require 'digest'
require 'base64'

module SmartId
  module Utils
    class AuthenticationHash
      attr_reader :hash_data
      
      def initialize(hash_data = nil)
        @hash_data = hash_data || random_bytes
      end
      
      def calculate_digest
        Digest::SHA256.digest(hash_data)
      end

      def calculate_base64_digest
        Base64.strict_encode64(calculate_digest)
      end

      private

      def random_bytes
        OpenSSL::Random.random_bytes(64)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
smart_id-0.1.0 lib/smart_id/utils/authentication_hash.rb