Using Crypto

Crypto (vapor/crypto) is a library containing common APIs related to cryptography and data generation. The package contains two modules:

  • Crypto
  • Random

With Vapor

This package is included with Vapor by default, just add:

  1. import Crypto
  2. import Random

Without Vapor

To include it in your package, add the following to your Package.swift file.

  1. // swift-tools-version:4.0
  2. import PackageDescription
  3. let package = Package(
  4. name: "Project",
  5. dependencies: [
  6. ...
  7. .package(url: "https://github.com/vapor/crypto.git", .upToNextMajor(from: "x.0.0")),
  8. ],
  9. targets: [
  10. .target(name: "Project", dependencies: ["Crypto", "Random", ... ])
  11. ]
  12. )

Use import Crypto to access Crypto’s APIs and import Random to access Random’s APIs.