module NdrImport::File::OfficeFileHelper
This mixin provides helper methods of MS Office files
Private Instance Methods
decrypted_file_string(path, password)
click to toggle source
This method decrypts a (modern) password protected MS Office document returning a String of the decrypted file
# File lib/ndr_import/file/office_file_helper.rb, line 11 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