Skip to content

Commit

Permalink
Merge pull request #134 from mattrubin/readme-base32-example
Browse files Browse the repository at this point in the history
Fix the Base32-decoding function in the token creation example code
  • Loading branch information
mattrubin authored Feb 10, 2017
2 parents 7a6804d + ff105ab commit 4c099be
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,14 @@ if let token = Token(url: url) {

To create a generator and a token from user input:

> This example assumes the user provides the secret as a Base32-encoded string. To use the decoding function seen below, add `import Base32` to the top of your Swift file.
````swift
let name = "..."
let issuer = "..."
let secretString = "..."

guard let secretData = Data(base32String: secretString),
guard let secretData = MF_Base32Codec.data(fromBase32String: secretString),
!secretData.isEmpty else {
print("Invalid secret")
return nil
Expand Down

0 comments on commit 4c099be

Please sign in to comment.