THOTP

1.0.66

Time-base & HMAC-based one-time password generator for iOS, tvOS, watchOS, and macOS
ericlewis/THOTP

What's New

1.0.66

2023-06-01T12:13:59Z

What's Changed

  • Extend the API to cover all use cases to grab the issuer parameter from the URL by @goppinath in #16

Full Changelog: 1.0.65...1.0.66

THOTP Logo

Build Status License: MIT Swift: 5.1 SwiftPM: Compatible Platforms: iOS – tvOS – watchOS - macOS

InstallationUsageDocumentationLicenseIssuesPull Requests

TOTP & HOTP generator for iOS, tvOS, watchOS, and macOS

Pure Swift implementation of time-based and HMAC-based one-time password generators. Heavily inspired by the OneTimePassword library from @mattrubin. Protocol based design, so you won't find any subclasses here.

Installation

THOTP can be installed via Swift Package Manager.

Supported platforms are iOS (13.0+), tvOS (13.0+), watchOS (6.0+), and macOS (10.15+).

Swift Package Manager

The easiest integration is to use the built in package manager tools in Xcode 11.0+. You can also do it manually.

Add the following as a dependency to your Package.swift:

.package(url: "https://github.com/ericlewis/THOTP.git", .upToNextMajor(from: "1.0.0"))

After specifying THOTP as a dependency of the target in which you want to use it, run:

swift package update

Usage

By default, this includes basic concrete types for Password & Generators. If you are interested in persistence, there are a couple of options to choose from:

  • Implement PasswordProtocol with your own concrete type, such as NSManagedObject
  • Use Valet-THOTP, which adds extensions + a new concrete type for easily persisting using Valet

Basic

The simplest usage is to parse a URL. THOTP is compatible with Google Authenticator's URI Scheme.

let password = try? Password(url: URL(string: "otpauth://totp/test?secret=GEZDGNBV")!)
print(password.currentPassword) // 123321

Documentation

Docs are generated with jazzy & can be found here. The process is currently manual, so it's possible for documentation to be out of date. Tests are a great way to see how to use this library.

License

This library is released under the MIT License. See LICENSE for details.

Description

  • Swift Tools 5.1.0
View More Packages from this Author

Dependencies

Last updated: Tue Oct 29 2024 13:54:48 GMT-0900 (Hawaii-Aleutian Daylight Time)