Sha256: 9cc18f631bddb84eb18d9374102d75b5c981e1297b6f59857b734a9cd1ea22e0
Contents?: true
Size: 756 Bytes
Versions: 20
Compression:
Stored size: 756 Bytes
Contents
# frozen_string_literal: true module Alchemy # Provides methods to secure your picture attributes against DOS attacks. # class PictureAttributes SECURE_ATTRIBUTES = %w(id size crop crop_from crop_size quality upsample).freeze class << self # Secures given attributes # # @param attributes [Hash] # @return [String] # def secure(attributes) Digest::SHA1.hexdigest(joined_attributes(attributes))[0..15] end private # Takes attributes and joins them with the +security_token+ of your rails app. # def joined_attributes(attributes) attributes.stringify_keys.values_at(*SECURE_ATTRIBUTES, Rails.configuration.secret_token).join('-') end end end end
Version data entries
20 entries across 20 versions & 1 rubygems