Sha256: e4e9e5e4be936ad5f1a3dfe0c68f7cc9be5e3684667485b11951d75df01f7fdd

Contents?: true

Size: 735 Bytes

Versions: 3

Compression:

Stored size: 735 Bytes

Contents

class SlackSmartBot
  module Utils
    module Encryption
      def self.encrypt(data, config)
        if config.encrypt
          require "openssl"
          require "base64"

          key, iv = Utils::Encryption.encryption_get_key_iv(config)
          cipher = OpenSSL::Cipher::Cipher.new "AES-256-CBC"
          cipher.encrypt
          cipher.key = key
          cipher.iv = iv
          encrypted = cipher.update(data) + cipher.final
          encrypted = Base64.encode64(encrypted)
          if defined?(Thread.current)
            Thread.current[:encrypted] ||= []
            Thread.current[:encrypted] << data
          end
          return encrypted
        else
          return data
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
slack-smart-bot-1.14.2 lib/slack/smart-bot/utils/encryption/encrypt.rb
slack-smart-bot-1.14.1 lib/slack/smart-bot/utils/encryption/encrypt.rb
slack-smart-bot-1.14.0 lib/slack/smart-bot/utils/encryption/encrypt.rb