diff --git a/totp.go b/totp.go index 96f9b06..9aa7f75 100644 --- a/totp.go +++ b/totp.go @@ -55,7 +55,7 @@ func (otp *Totp) synchronizeCounter(offset int) { // Label returns the combination of issuer:account string func (otp *Totp) label() string { - return url.QueryEscape(fmt.Sprintf("%s:%s", otp.issuer, otp.account)) + return fmt.Sprintf("%s:%s", url.QueryEscape(otp.issuer), otp.account) } // Counter returns the TOTP's 8-byte counter as unsigned 64-bit integer. @@ -275,7 +275,7 @@ func calculateToken(counter []byte, digits int, h hash.Hash) string { // 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) { +func (otp *Totp) url() (string, error) { // verify the proper initialization if err := totpHasBeenInitialized(otp); err != nil { @@ -316,7 +316,7 @@ func (otp *Totp) URL() (string, error) { func (otp *Totp) QR() ([]byte, error) { // get the URL - u, err := otp.URL() + u, err := otp.url() // check for errors during initialization // this is already done on the URL method diff --git a/totp_test.go b/totp_test.go index a065894..d3873b7 100644 --- a/totp_test.go +++ b/totp_test.go @@ -275,12 +275,12 @@ func TestSerialization(t *testing.T) { t.Error("Deserialized hash property differ from original TOTP") } - deserializedUrl, err := deserializedOTP.URL() + deserializedUrl, err := deserializedOTP.url() if err != nil { t.Error(err) } - otpdUrl, err := otp.URL() + otpdUrl, err := otp.url() if err != nil { t.Error(err) } @@ -309,7 +309,7 @@ func TestSerialization(t *testing.T) { func TestProperInitialization(t *testing.T) { otp := Totp{} - if _, err := otp.URL(); err == nil { + if _, err := otp.url(); err == nil { t.Fatal("Totp is not properly initialized and the method did not catch it") } }