Module: SecureHeaders::HashHelper

Included in:
ViewHelpers
Defined in:
lib/secure_headers/hash_helper.rb

Instance Method Summary collapse

Instance Method Details

#hash_source(inline_script, digest = :SHA256) ⇒ Object



6
7
8
9
# File 'lib/secure_headers/hash_helper.rb', line 6

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