Sha256: e4237585e6c8bad344d123f0d70c78667c9ee6c9a6af3931d10f4e4d14e71c83

Contents?: true

Size: 553 Bytes

Versions: 17

Compression:

Stored size: 553 Bytes

Contents

# frozen_string_literal: true

module Decidim
  class AttributeEncryptor
    def self.encrypt(string)
      cryptor.encrypt_and_sign(string) if string.present?
    end

    def self.decrypt(string_encrypted)
      cryptor.decrypt_and_verify(string_encrypted) if string_encrypted.present?
    end

    def self.cryptor
      key = ActiveSupport::KeyGenerator.new("attribute").generate_key(
        Rails.application.secrets.secret_key_base, ActiveSupport::MessageEncryptor.key_len
      )
      ActiveSupport::MessageEncryptor.new(key)
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
decidim-core-0.23.6 lib/decidim/attribute_encryptor.rb
decidim-core-0.23.5 lib/decidim/attribute_encryptor.rb
decidim-core-0.23.4 lib/decidim/attribute_encryptor.rb
decidim-core-0.24.0.rc1 lib/decidim/attribute_encryptor.rb
decidim-core-0.23.3 lib/decidim/attribute_encryptor.rb
decidim-core-0.23.2 lib/decidim/attribute_encryptor.rb
decidim-core-0.23.1 lib/decidim/attribute_encryptor.rb
decidim-core-0.23.1.rc1 lib/decidim/attribute_encryptor.rb
decidim-core-0.23.0 lib/decidim/attribute_encryptor.rb
decidim-core-0.22.0 lib/decidim/attribute_encryptor.rb
decidim-core-0.21.0 lib/decidim/attribute_encryptor.rb
decidim-core-0.20.1 lib/decidim/attribute_encryptor.rb
decidim-core-0.20.0 lib/decidim/attribute_encryptor.rb
decidim-core-0.19.1 lib/decidim/attribute_encryptor.rb
decidim-core-0.18.1 lib/decidim/attribute_encryptor.rb
decidim-core-0.19.0 lib/decidim/attribute_encryptor.rb
decidim-core-0.18.0 lib/decidim/attribute_encryptor.rb