Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OTP Generators #71

Merged
merged 3 commits into from
Jul 24, 2018
Merged

Add OTP Generators #71

merged 3 commits into from
Jul 24, 2018

Conversation

hzalaz
Copy link
Member

@hzalaz hzalaz commented Jul 24, 2018

Now you can generate OTP codes using Guardian SDK (HOTP or TOTP), for TOTP you can obtain the generator

let secret: Data
let totp = try Guardian.totp(secret: secret, algorithm: .sha1) // Default 6 digits

// or use more digits and a diff hmac alg
let totp = try Guardian.totp(secret: secret, algorithm: .sha256, digits: 8)

and then to generate the code

let code = totp.new() // using current time and 30s period

// or passing date and period
let code = totp.new(time: Date().timeIntervalSince1970, period: 45)

@hzalaz hzalaz added this to the v0-Next milestone Jul 24, 2018
@hzalaz hzalaz force-pushed the add-otp-generators branch from c43e9af to 1deefe6 Compare July 24, 2018 21:31
@hzalaz hzalaz merged commit 5210284 into master Jul 24, 2018
@hzalaz hzalaz deleted the add-otp-generators branch July 24, 2018 21:37
@hzalaz hzalaz modified the milestones: v0-Next, 1.0.0 Jul 31, 2018
@hzalaz hzalaz mentioned this pull request Jul 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant