https://github.com/sparrowcode/otp
Generating OTP one-time passwords in Swift.
https://github.com/sparrowcode/otp
2fa one-time-password one-time-passwords otp otp-applications otp-codes otp-generator otp-library otp-verification swift
Last synced: 21 days ago
JSON representation
Generating OTP one-time passwords in Swift.
- Host: GitHub
- URL: https://github.com/sparrowcode/otp
- Owner: sparrowcode
- License: mit
- Created: 2022-06-22T07:36:23.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-06-23T17:59:18.000Z (almost 3 years ago)
- Last Synced: 2025-04-07T20:21:24.851Z (about 2 months ago)
- Topics: 2fa, one-time-password, one-time-passwords, otp, otp-applications, otp-codes, otp-generator, otp-library, otp-verification, swift
- Language: Swift
- Homepage:
- Size: 17.6 KB
- Stars: 17
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# One Time Password
## Navigate
- [Installation](#installation)
- [Swift Package Manager](#swift-package-manager)
- [CocoaPods](#cocoapods)
- [Manually](#manually)
- [Usage](#usage)
- [Apps Using](#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`:
```swift
dependencies: [
.package(url: "https://github.com/sparrowcode/OTP", .upToNextMajor(from: "1.0.0"))
]
```### CocoaPods:
Specify it in your `Podfile`:
```ruby
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
```swift
// 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.