Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Songhurst committed Feb 21, 2018
2 parents 0f38eb2 + d22311d commit 4ec5c3f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions totp.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,14 @@ func calculateToken(counter []byte, digits int, h hash.Hash) string {
return fmt.Sprintf(fmtStr, mod)
}

// Secret returns the underlying base32 encoded secret.
// This should only be displayed the first time a user enables 2FA,
// and should be transmitted over a secure connection.
// Useful for supporting TOTP clients that don't support QR scanning.
func (otp *Totp) Secret() string {
return base32.StdEncoding.EncodeToString(otp.key)
}

// URL returns a suitable URL, such as for the Google Authenticator app
// example: otpauth://totp/Example:alice@google.com?secret=JBSWY3DPEHPK3PXP&issuer=Example
func (otp *Totp) url() (string, error) {
Expand Down

0 comments on commit 4ec5c3f

Please sign in to comment.