Module: Rawfeed::CspFilters

Defined in:
lib/rawfeed/csp_filters.rb

Instance Method Summary collapse

Instance Method Details

#sha256_base64(input) ⇒ Object

Generates a SHA256 hash and encodes it in Base64, ready for use in a CSP.



11
12
13
14
15
16
# File 'lib/rawfeed/csp_filters.rb', line 11

def sha256_base64(input)
  # Calculates the SHA256 hash of the input text.
  hash = Digest::SHA256.digest(input)
  # Encodes the result in strict Base64 (no line breaks).
  Base64.strict_encode64(hash)
end