Enforce positive numbers with UInt
-
generateOTP(secret: Data, algorithm: OTPAlgorithm = .sha1, counter: UInt64, digits: Int = 6) -> Stringwas returningString?but there wasn't a way in which it could returnnil -
func generate(secondsPast1970: UInt) -> Stringno longer returns an optional. Positive integer is enforced viaUIntusage. -
func validateTime(time: Int) -> Booldeleted as no longer a need to validate positive integer.
I saw your comment here @lachlanbell about UInt64 being in the spec but I couldn't see it. https://github.com/lachlanbell/SwiftOTP/issues/2#issuecomment-384644490
Hi @ptrkstr, thanks for the PR!
Really sorry, I haven't had a chance to properly review this yet due to other commitments eating up almost all of my free time. I'll give this a proper look soon.
Regarding the spec, it mentions that the counter value C should be 8 bytes (=64 bits), so from a preliminary look I think UInt64 should still be used. The UInt64 type isn't hardware dependent, so it should work on 32-bit systems as well.
Hey @lachlanbell, Thanks for the reply, no apology necessary :) Ahh great point, let me revert the UInt64 changes. I think there's value in the other changes I've made regarding UInt over Int to avoid a guard for negative number checking. I'll comment back when it's done.
Hey @lachlanbell, I've reverted the UInt64 changes, ready for review.