Sha256: 8c73d0ad1cc2597a40b44fe50d7e66421f2b759fde2d136f873d44239c6af3b8

Contents?: true

Size: 1.36 KB

Versions: 38

Compression:

Stored size: 1.36 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")
      return if result[:button] == :cancel
      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")
      return if result[:button] == :cancel
      pw = result[:value]
      doc.text = Encryption.encrypt(doc.to_s, pw)
    end
  end
end

Version data entries

38 entries across 38 versions & 2 rubygems

Version Path
redcar-0.13 plugins/encryption/encryption.rb
redcar-dev-0.13.5dev plugins/encryption/encryption.rb
redcar-dev-0.13.4dev plugins/encryption/encryption.rb
redcar-dev-0.13.3dev plugins/encryption/encryption.rb
redcar-dev-0.13.2dev plugins/encryption/encryption.rb
redcar-dev-0.13.1dev plugins/encryption/encryption.rb
redcar-0.12.1 plugins/encryption/encryption.rb
redcar-dev-0.13.0dev plugins/encryption/encryption.rb
redcar-0.12 plugins/encryption/encryption.rb
redcar-dev-0.12.27dev plugins/encryption/encryption.rb
redcar-dev-0.12.26dev plugins/encryption/encryption.rb
redcar-dev-0.12.25dev plugins/encryption/encryption.rb
redcar-dev-0.12.24dev plugins/encryption/encryption.rb
redcar-dev-0.12.23dev plugins/encryption/encryption.rb
redcar-dev-0.12.22dev plugins/encryption/encryption.rb
redcar-dev-0.12.21dev plugins/encryption/encryption.rb
redcar-dev-0.12.20dev plugins/encryption/encryption.rb
redcar-dev-0.12.19dev plugins/encryption/encryption.rb
redcar-dev-0.12.18dev plugins/encryption/encryption.rb
redcar-dev-0.12.17dev plugins/encryption/encryption.rb