CryptoOffice

0.1.1

Office Open XML (OOXML) formats (.xlsx, .docx, .pptx) decryption for Swift
CoreOffice/CryptoOffice

What's New

2020-08-27T13:35:39Z

This is a bugfix release that fixes incorrect padding applied to files of a certain size during decryption.

Merged pull requests:

CryptoOffice

Office Open XML (OOXML) formats (.xlsx, .docx, .pptx) decryption for Swift

CryptoOffice is a library for decrypting Microsoft Office formats that utilise ECMA-376 agile encryption. It should be used in conjuction with libraries that allow parsing decrypted data, such as CoreXLSX.

Example

Using CryptoOffice is easy:

  1. Add import CryptoOffice at the top of a relevant Swift source file.
  2. Use CryptoOfficeFile(path: String) to create a new instance with a path to your encrypted file.
  3. Call decrypt(password: String) on it to get decrypted data.
  4. Parse the decrypted data with a library appropriate for that format (CoreXLSX in this example).
import CoreXLSX
import CryptoOffice

let encryptedFile = try CryptoOfficeFile(path: "./categories.xlsx")
let decryptedData = try encryptedFile.decrypt(password: "pass")
let xlsx = try XLSXFile(data: decryptedData)

for path in try xlsx.parseWorksheetPaths() {
  let worksheet = try xlsx.parseWorksheet(at: path)
  for row in worksheet.data?.rows ?? [] {
    for c in row.cells {
      print(c)
    }
  }
}

Requirements

Apple Platforms

  • Xcode 11.0 or later
  • Swift 5.1 or later
  • iOS 13.0 / watchOS 6.0 / tvOS 13.0 / macOS 10.15 or later deployment targets

Linux

  • Swift 5.1 or later

Installation

Swift Package Manager

Swift Package Manager is a tool for managing the distribution of Swift code. It’s integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies on all platforms.

Once you have your Swift package set up, adding CryptoOffice as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
  .package(url: "https://github.com/CoreOffice/CryptoOffice.git",
           .upToNextMinor(from: "0.1.1"))
]

If you're using CryptoOffice in an app built with Xcode, you can also add it as a direct dependency using Xcode's GUI.

Contributing

Sponsorship

If this library saved you any amount of time or money, please consider sponsoring the work of its maintainer. While some of the sponsorship tiers give you priority support or even consulting time, any amount is appreciated and helps in maintaining the project.

Coding Style

This project uses SwiftFormat and SwiftLint to enforce formatting and coding style. We encourage you to run SwiftFormat within a local clone of the repository in whatever way works best for you either manually or automatically via an Xcode extension, build phase or git pre-commit hook etc.

To guarantee that these tools run before you commit your changes on macOS, you're encouraged to run this once to set up the pre-commit hook:

brew bundle # installs SwiftLint, SwiftFormat and pre-commit
pre-commit install # installs pre-commit hook to run checks before you commit

Refer to the pre-commit documentation page for more details and installation instructions for other platforms.

SwiftFormat and SwiftLint also run on CI for every PR and thus a CI build can fail with incosistent formatting or style. We require CI builds to pass for all PRs before merging.

Code of Conduct

This project adheres to the Contributor Covenant Code of Conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to conduct@coreoffice.org.

License

CryptoOffice is licensed under the Apache License, Version 2.0 (the "License"); you may not use this library except in compliance with the License. See the LICENSE file for more info.

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

CryptoOffice uses swift-crypto, CryptoSwift, XMLCoder, OLEKit and ZIPFoundation. The latter is only a dependency of CryptoOffice's test suite. Please check the respective projects for their actual licensing information.

Description

  • Swift Tools 5.1.0
View More Packages from this Author

Dependencies

Last updated: Thu Nov 21 2024 11:13:38 GMT-1000 (Hawaii-Aleutian Standard Time)