Sha256: c873766924c5961c9f49af804fa90e97da999e15b2f5f452ae8f3553b49420c6

Contents?: true

Size: 1.19 KB

Versions: 9

Compression:

Stored size: 1.19 KB

Contents


module Encryption
  def self.menus
    Redcar::Menu::Builder.build do
      sub_menu "Plugins" do
        sub_menu "Encryption" do
          item "Encrypt Document", EncryptDocumentCommand
          item "Decrypt Document", DecryptDocumentCommand
        end
      end
    end
  end

  def self.lazy_load
    $:.push File.expand_path(File.join(Redcar.root, "openssl", "lib"))
    require 'openssl'

    require File.dirname(__FILE__) + "/jarmor-1.1"
    require File.dirname(__FILE__) + "/ezcrypto"
  end

  class DecryptDocumentCommand < Redcar::EditTabCommand
    def execute
      Encryption.lazy_load
      result = Redcar::Application::Dialog.input("Password", "Enter password")
      pw = result[:value]
      begin
        doc.text = EncryptionTools.dearmour_and_decrypt(doc.to_s, pw)
      rescue => e
        Redcar::Application::Dialog.message_box("Couldn't decrypt!", :type => :error)
      end
    end
  end
  
  class EncryptDocumentCommand < Redcar::EditTabCommand
    def execute
      Encryption.lazy_load
      result = Redcar::Application::Dialog.input("Password", "Enter password")
      pw = result[:value]
      doc.text = EncryptionTools.encrypt_and_armour(doc.to_s, pw)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
redcar-0.3.8.4 plugins/encryption/encryption.rb
redcar-0.3.8.3 plugins/encryption/encryption.rb
redcar-0.3.8.2 plugins/encryption/encryption.rb
redcar-0.3.8.1 plugins/encryption/encryption.rb
redcar-0.3.8 plugins/encryption/encryption.rb
redcar-0.3.7.1 plugins/encryption/encryption.rb
redcar-0.3.7 plugins/encryption/encryption.rb
redcar-0.3.6 plugins/encryption/encryption.rb
redcar-0.3.5 plugins/encryption/encryption.rb