Skip to content

Commit

Permalink
Update examples with json export.
Browse files Browse the repository at this point in the history
  • Loading branch information
jltorresm committed Sep 9, 2020
1 parent 1c4d972 commit 43e85bc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
10 changes: 7 additions & 3 deletions examples/hotp/main.go
@@ -1,6 +1,7 @@
package main

import (
"encoding/json"
"fmt"
"log"

Expand Down Expand Up @@ -54,8 +55,11 @@ func main() {
ku := h.KeyUri(aUsername, anIssuer)

// From here you can get the plain text uri.
msg = "Exporting config for \"%s\" at \"%s\":\n\t- Plain URI --> %s\n\t- QR code image, base 64 encoded (" +
"truncated to save space) --> %s...\n"
msg = "Exporting config for \"%s\" at \"%s\":\n" +
"\t- Plain URI --> %s\n" +
"\t- QR code image, base 64 encoded (truncated to save space) --> %s...\n" +
"\t- JSON --> %s\n"
qr, _ := ku.QRCode()
fmt.Printf(msg, aUsername, anIssuer, ku.String(), qr[0:200])
jsonParams, _ := json.Marshal(ku)
fmt.Printf(msg, aUsername, anIssuer, ku.String(), qr[0:200], jsonParams)
}
10 changes: 7 additions & 3 deletions examples/totp/main.go
@@ -1,6 +1,7 @@
package main

import (
"encoding/json"
"fmt"
"log"

Expand Down Expand Up @@ -46,8 +47,11 @@ func main() {
ku := t.KeyUri(aUsername, anIssuer)

// From here you can get the plain text uri.
msg = "Exporting config for \"%s\" at \"%s\":\n\t- Plain URI --> %s\n\t- QR code image, base 64 encoded (" +
"truncated to save space) --> %s...\n"
msg = "Exporting config for \"%s\" at \"%s\":\n" +
"\t- Plain URI --> %s\n" +
"\t- QR code image, base 64 encoded (truncated to save space) --> %s...\n" +
"\t- JSON --> %s\n"
qr, _ := ku.QRCode()
fmt.Printf(msg, aUsername, anIssuer, ku.String(), qr[0:200])
jsonParams, _ := json.Marshal(ku)
fmt.Printf(msg, aUsername, anIssuer, ku.String(), qr[0:200], jsonParams)
}

0 comments on commit 43e85bc

Please sign in to comment.