diff --git a/lib/secure_headers/hash_helper.rb b/lib/secure_headers/hash_helper.rb
index <HASH>..<HASH> 100644
--- a/lib/secure_headers/hash_helper.rb
+++ b/lib/secure_headers/hash_helper.rb
@@ -1,7 +1,9 @@
+require 'base64'
+
 module SecureHeaders
   module HashHelper
     def hash_source(inline_script, digest = :SHA256)
-      base64_hashed_content = Digest.const_get(digest).hexdigest(inline_script)].pack("H*")].pack("m").chomp
+      base64_hashed_content = Base64.encode64(Digest.const_get(digest).digest(inline_script)).chomp
       "'#{digest.to_s.downcase}-#{base64_hashed_content}'"
     end
   end
oops, hash_source method regressed