Swiftpack.co - Package - backslash-f/aescryptable

swift-5.0 package%20manager-compatible build status

AESCryptable

Provides Advanced Encryption Standard (AES) capabilities.

Integration

In your Package.swift, add AESCryptable as a dependency:

dependencies: [
  // 🔐 AES encryption/decryption with random iv. Swift 5 and up.
  .package(url: "https://github.com/backslash-f/aescryptable", from: "1.0.0")
],

Associate the dependency with your target:

targets: [
  .target(name: "App", dependencies: ["AESCryptable"])
]

Run: swift build

Usage

import AESCryptable

do {
  // encrypt
  let aes = try AES(keyString: "01234567890123456789012345678901")
  let encryptedData = try aes.encrypt("The black knight always triumphs!")

  // decrypt
  let decryptedString = try aes.decrypt(encryptedData)
  print(decryptedString) // The black knight always triumphs!

} catch {
  print(error)
}

(Refer to the test class for a high-level overview.)

Demo

Clone the repo and use AESCryptable.playground to see the code in action:

AESCryptable Demo

Github

link
Stars: 0
Help us keep the lights on

Dependencies

Used By

Total: 0

Releases

v1.0.3 - Apr 4, 2019

v1.0.2 - Apr 4, 2019

Kudos to the user Leo from SO:

  • Favor Data(string.utf8) over string.data(using: .utf8)
  • Remove stringToDataFailed error

Also added a Playground to make it easier to see the code in action.

v1.0.1 - Apr 3, 2019

  • Bring back random iv generation
  • Remove NSData.bytes usage

v1.0.0 - Mar 31, 2019