Sha256: 48cbbf4dc1028c2db0174afb0ee8110da40ea3ce8417019aa21b6a1d5127f86f

Contents?: true

Size: 832 Bytes

Versions: 3

Compression:

Stored size: 832 Bytes

Contents

# frozen_string_literal: true

require_relative '../components/crypto'

module NanoBot
  module Controllers
    module Security
      def self.decrypt(content)
        Components::Crypto.decrypt(content)
      end

      def self.encrypt(content, soft: false)
        Components::Crypto.encrypt(content, soft:)
      end

      def self.check
        password = ENV.fetch('NANO_BOTS_ENCRYPTION_PASSWORD', nil)
        password = 'UNSAFE' unless password && password != ''

        {
          encryption: (
            Components::Crypto.encrypt('SAFE') != 'SAFE' &&
            Components::Crypto.encrypt('SAFE') != Components::Crypto.encrypt('SAFE') &&
            Components::Crypto.decrypt(Components::Crypto.encrypt('SAFE')) == 'SAFE'
          ),
          password: password != 'UNSAFE'
        }
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
nano-bots-1.0.0 controllers/security.rb
nano-bots-0.1.1 controllers/security.rb
nano-bots-0.1.0 controllers/security.rb