OTP icon indicating copy to clipboard operation
OTP copied to clipboard

Generating OTP one-time passwords in Swift.

One Time Password

Navigate

  • Installation
    • Swift Package Manager
    • CocoaPods
    • Manually
  • Usage
  • Apps Using

Installation

Ready to use on iOS 13+, tvOS 13+ & watchOS 6+

Swift Package Manager

In Xcode go to File -> Packages -> Update to Latest Package Versions and insert url:

https://github.com/sparrowcode/OTP

or adding it to the dependencies value of your Package.swift:

dependencies: [
    .package(url: "https://github.com/sparrowcode/OTP", .upToNextMajor(from: "1.0.0"))
]

CocoaPods:

Specify it in your Podfile:

pod 'OTP'

Manually

If you prefer not to use any of dependency managers, you can integrate manually. Put Sources/OTP folder in your Xcode project. Make sure to enable Copy items if needed and Create groups.

Usage

// With default parametrs
let password = OTP.generateOTP(secret: "secret")

// With custom values
let password = OTP.generateOTP(secret: "secret", algorithm: OTPAlgorithm = .sha1, expirationTimeInSeconds: Int = 30, digits: Int = 6)

Apps Using

If you use a OTP, add your application via Pull Request.