Sha256: 36ceee58532038fac1a797a132401fa8f029e37a01cc0ef3a88c857c130419a2

Contents?: true

Size: 319 Bytes

Versions: 34

Compression:

Stored size: 319 Bytes

Contents

# frozen_string_literal: true
require "base64"

module SecureHeaders
  module HashHelper
    def hash_source(inline_script, digest = :SHA256)
      base64_hashed_content = Base64.encode64(Digest.const_get(digest).digest(inline_script)).chomp
      "'#{digest.to_s.downcase}-#{base64_hashed_content}'"
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
secure_headers-7.1.0 lib/secure_headers/hash_helper.rb
secure_headers-7.0.0 lib/secure_headers/hash_helper.rb
secure_headers-6.7.0 lib/secure_headers/hash_helper.rb
secure_headers-6.6.0 lib/secure_headers/hash_helper.rb
secure_headers-6.5.0 lib/secure_headers/hash_helper.rb
secure_headers-6.4.0 lib/secure_headers/hash_helper.rb
secure_headers-6.3.4 lib/secure_headers/hash_helper.rb
secure_headers-6.3.3 lib/secure_headers/hash_helper.rb
secure_headers-6.3.2 lib/secure_headers/hash_helper.rb
secure_headers-6.3.1 lib/secure_headers/hash_helper.rb
secure_headers-5.2.0 lib/secure_headers/hash_helper.rb
secure_headers-6.3.0 lib/secure_headers/hash_helper.rb
secure_headers-5.1.0 lib/secure_headers/hash_helper.rb
secure_headers-6.2.0 lib/secure_headers/hash_helper.rb
secure_headers-6.1.2 lib/secure_headers/hash_helper.rb
secure_headers-6.1.1 lib/secure_headers/hash_helper.rb
secure_headers-6.1.0 lib/secure_headers/hash_helper.rb
secure_headers-6.0.0 lib/secure_headers/hash_helper.rb
secure_headers-6.0.0.alpha03 lib/secure_headers/hash_helper.rb
secure_headers-6.0.0.alpha02 lib/secure_headers/hash_helper.rb