diff options
author | icebaker <113217272+icebaker@users.noreply.github.com> | 2023-06-03 20:37:14 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-03 20:37:14 -0300 |
commit | bffbac01eeb00e5f94cd4d675edc0a0566354265 (patch) | |
tree | 39df8578dd2bbed230e0d222d0175e088f97537e /controllers/security.rb | |
parent | 2c50a06b68a21ce904e5dfd15833e3569ff64bfa (diff) | |
parent | 1be75c768ca9595b54d8e2d5a8287adbc950f659 (diff) |
Merge pull request #3 from icebaker/ib-cryptography
Cryptography and Security
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 |