Sha256: 8636a5ace807bc4b16048d978a756c851c06fd1ae2f694754da003e681d86179

Contents?: true

Size: 675 Bytes

Versions: 22

Compression:

Stored size: 675 Bytes

Contents

require 'ooxml_decrypt'

module NdrImport
  module File
    # This mixin provides helper methods of MS Office files
    module OfficeFileHelper
      private

      # This method decrypts a (modern) password protected MS Office document
      # returning a String of the decrypted file
      def decrypted_file_string(path, password)
        # Ensure password is a binary representation of a UTF-16LE string
        # e.g. 'password' should be represented as "p\0\a\s\0[...]"
        password = password.encode('utf-16le').bytes.pack('c*').encode('binary')

        OoxmlDecrypt::EncryptedFile.decrypt(SafeFile.safepath_to_string(path), password)
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
ndr_import-11.2.1 lib/ndr_import/file/office_file_helper.rb
ndr_import-11.2.0 lib/ndr_import/file/office_file_helper.rb
ndr_import-11.1.0 lib/ndr_import/file/office_file_helper.rb
ndr_import-11.0.2 lib/ndr_import/file/office_file_helper.rb
ndr_import-11.0.1 lib/ndr_import/file/office_file_helper.rb
ndr_import-11.0.0 lib/ndr_import/file/office_file_helper.rb
ndr_import-10.3.0 lib/ndr_import/file/office_file_helper.rb
ndr_import-10.2.0 lib/ndr_import/file/office_file_helper.rb
ndr_import-10.1.3 lib/ndr_import/file/office_file_helper.rb
ndr_import-10.1.2 lib/ndr_import/file/office_file_helper.rb
ndr_import-10.1.1 lib/ndr_import/file/office_file_helper.rb
ndr_import-10.1 lib/ndr_import/file/office_file_helper.rb
ndr_import-10.0 lib/ndr_import/file/office_file_helper.rb
ndr_import-9.1.0 lib/ndr_import/file/office_file_helper.rb
ndr_import-9.0.3 lib/ndr_import/file/office_file_helper.rb
ndr_import-9.0.2 lib/ndr_import/file/office_file_helper.rb
ndr_import-9.0.1 lib/ndr_import/file/office_file_helper.rb
ndr_import-9.0.0 lib/ndr_import/file/office_file_helper.rb
ndr_import-8.6.0 lib/ndr_import/file/office_file_helper.rb
ndr_import-8.5.2 lib/ndr_import/file/office_file_helper.rb