Sha256: f3252ce7fab924d87ac1964fe1c99f235a05b4251785cf823dbc93851a4e7bcf

Contents?: true

Size: 1.27 KB

Versions: 23

Compression:

Stored size: 1.27 KB

Contents


module Encryption
  def self.encrypt(text, password)
    EncryptionTools.encrypt_and_armour(text, password)
  end
  
  def self.decrypt(text, password)
    EncryptionTools.dearmour_and_decrypt(text, password)
  end
  
  def self.menus
    Redcar::Menu::Builder.build do
      sub_menu "Plugins" do
        sub_menu "Encryption", :priority => 55 do
          item "Encrypt Document", EncryptDocumentCommand
          item "Decrypt Document", DecryptDocumentCommand
        end
      end
    end
  end

  def self.lazy_load
    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 = Encryption.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 = Encryption.encrypt(doc.to_s, pw)
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
redcar-0.9.2 plugins/encryption/encryption.rb
redcar-0.9.1 plugins/encryption/encryption.rb
redcar-0.9.0 plugins/encryption/encryption.rb
redcar-0.8.1 plugins/encryption/encryption.rb
redcar-0.8 plugins/encryption/encryption.rb
redcar-0.7 plugins/encryption/encryption.rb
redcar-0.6.1 plugins/encryption/encryption.rb
redcar-0.6 plugins/encryption/encryption.rb
redcar-0.6.1dev plugins/encryption/encryption.rb
redcar-0.5.1 plugins/encryption/encryption.rb
redcar-0.5 plugins/encryption/encryption.rb
redcar-0.5.6dev plugins/encryption/encryption.rb
redcar-0.5.5dev plugins/encryption/encryption.rb
redcar-0.5.4dev plugins/encryption/encryption.rb
redcar-0.5.3dev plugins/encryption/encryption.rb
redcar-0.5.2dev plugins/encryption/encryption.rb
redcar-0.5.1dev plugins/encryption/encryption.rb
redcar-0.4.1 plugins/encryption/encryption.rb
redcar-0.4 plugins/encryption/encryption.rb
redcar-0.3.10.1dev plugins/encryption/encryption.rb