Sha256: dddc9ad7078e3a92096c0f3bda08512de4d1bc798161c0d312b83b888a376107

Contents?: true

Size: 736 Bytes

Versions: 148

Compression:

Stored size: 736 Bytes

Contents

# frozen_string_literal: true

require 'digest/sha2'

module GraphQL
  class Query
    # @api private
    # @see Query#query_fingerprint
    # @see Query#variables_fingerprint
    # @see Query#fingerprint
    module Fingerprint
      # Make an obfuscated hash of the given string (either a query string or variables JSON)
      # @param string [String]
      # @return [String] A normalized, opaque hash
      def self.generate(input_str)
        # Implemented to be:
        # - Short (and uniform) length
        # - Stable
        # - Irreversibly Opaque (don't want to leak variable values)
        # - URL-friendly
        bytes = Digest::SHA256.digest(input_str)
        Base64.urlsafe_encode64(bytes)
      end
    end
  end
end

Version data entries

148 entries across 148 versions & 2 rubygems

Version Path
graphql-2.1.4 lib/graphql/query/fingerprint.rb
graphql-1.13.20 lib/graphql/query/fingerprint.rb
graphql-2.1.3 lib/graphql/query/fingerprint.rb
graphql-2.1.2 lib/graphql/query/fingerprint.rb
graphql-2.1.1 lib/graphql/query/fingerprint.rb
graphql-2.1.0 lib/graphql/query/fingerprint.rb
graphql-2.0.27 lib/graphql/query/fingerprint.rb
graphql-2.0.26 lib/graphql/query/fingerprint.rb
graphql-2.0.25 lib/graphql/query/fingerprint.rb
graphql-2.0.24 lib/graphql/query/fingerprint.rb
graphql-2.0.23 lib/graphql/query/fingerprint.rb
graphql-2.0.22 lib/graphql/query/fingerprint.rb
graphql-2.0.21 lib/graphql/query/fingerprint.rb
graphql-2.0.20 lib/graphql/query/fingerprint.rb
graphql-2.0.17.2 lib/graphql/query/fingerprint.rb
graphql-2.0.17.1 lib/graphql/query/fingerprint.rb
graphql-2.0.19 lib/graphql/query/fingerprint.rb
graphql-2.0.18 lib/graphql/query/fingerprint.rb
graphql-2.0.17 lib/graphql/query/fingerprint.rb
graphql-1.13.19 lib/graphql/query/fingerprint.rb