diff options
Diffstat (limited to 'controllers/security.rb')
-rw-r--r-- | controllers/security.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/controllers/security.rb b/controllers/security.rb new file mode 100644 index 0000000..8f066a5 --- /dev/null +++ b/controllers/security.rb @@ -0,0 +1,27 @@ +# 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.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 |