Swiftpack.co - CoreOffice/CryptoOffice as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by CoreOffice.
CoreOffice/CryptoOffice 0.1.1
Office Open XML (OOXML) formats (.xlsx, .docx, .pptx) decryption for Swift
⭐️ 39
🕓 1 year ago
iOS macOS watchOS tvOS
.package(url: "https://github.com/CoreOffice/CryptoOffice.git", from: "0.1.1")

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.

Join our Discord for any questions and friendly banter.

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 12.4 or later
  • Swift 5.3 or later
  • iOS 13.0 / watchOS 6.0 / tvOS 13.0 / macOS 10.15 or later deployment targets

Linux

  • Swift 5.3 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

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 [email protected].

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.

GitHub

link
Stars: 39
Last commit: 1 year ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

3 years ago

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

Merged pull requests:

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics