OtpQRScanResult
public final class OtpQRScanResult : QRScanResultProtocol
The OtpQRScanResult
handles one-time password data scanned from a QR code.
-
Initializes a new
OtpQRScanResult
.Declaration
Swift
public init(type: String, issuer: String?, secret: String, username: String?, algorithm: HmacAlgorithm = HmacAlgorithm.sha1, digits: Int = 6, counter: Int?, period: Int?)
Parameters
type
The type of the QR scanned.
issuer
The name of the issuer providing the service.
secret
The secret value encoded in Base32.
username
The user associated with the service.
algorithm
The algorithm used to calculate the one-time password. The default is
HmacAlgorithm.SHA1
.digits
The length of the one-time password to be displayed. The default is 6.
counter
The counter is required for use with HOTP. It will set the initial counter value.
period
The period a TOTP code will be valid for, in seconds. The default value is 30.
-
Initializes a new
OtpQRScanResult
from aDictionary
.Declaration
Swift
public init?(_ data: [String : Any])
Parameters
data
The
Dictionary
of one-time password attributes.
-
The type of the QR scanned. Value must be either HOTP or TOTP.
Declaration
Swift
public fileprivate(set) var type: String
-
The name of the issuer providing the service.
Declaration
Swift
public fileprivate(set) var issuer: String?
-
The secret value encoded in Base32.
Declaration
Swift
public fileprivate(set) var secret: String
-
The username associated with the service.
Declaration
Swift
public fileprivate(set) var username: String?
-
The algorithm used to calculate the one-time password. The default is
HmacAlgorithm.SHA1
.Declaration
Swift
public fileprivate(set) var algorithm: HmacAlgorithm
-
The length of the one-time password to be displayed. The default is 6.
Declaration
Swift
public fileprivate(set) var digits: Int
-
The counter is required for use with HOTP. It will set the initial counter value.
Declaration
Swift
public fileprivate(set) var counter: Int
-
The period a TOTP code will be valid for, in seconds. The default value is 30.
Declaration
Swift
public fileprivate(set) var period: Int
-
Parses the incoming data from the QR code.
Remark
Google’s spec: https://github.com/google/google-authenticator/wiki/Key-Uri-FormatDeclaration
Swift
public static func parse(_ value: String?) -> OtpQRScanResult?
Parameters
value
The incoming string.
Return Value
An instance of
QRScanResultProtocol
, otherwisenil
.