Sha256: 03bb44274679f8a59de6b2761d4c5025b89ac1c7cf6387af550c9fe3f5a0b3ff
Contents?: true
Size: 686 Bytes
Versions: 69
Compression:
Stored size: 686 Bytes
Contents
# frozen_string_literal: true module Decidim module Initiatives # Service to encrypt and decrypt metadata class DataEncryptor attr_reader :secret def initialize(args = {}) @secret = args.fetch(:secret) || "default" @key = ActiveSupport::KeyGenerator.new(secret).generate_key( Rails.application.secrets.secret_key_base, ActiveSupport::MessageEncryptor.key_len ) @encryptor = ActiveSupport::MessageEncryptor.new(@key) end def encrypt(data) @encryptor.encrypt_and_sign(data) end def decrypt(encrypted_data) @encryptor.decrypt_and_verify(encrypted_data) end end end end
Version data entries
69 entries across 69 versions & 1 rubygems