Skip to content

Commit

Permalink
Update go docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
jltorresm committed Sep 2, 2020
1 parent b43d63c commit bcead87
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions authenticator/authenticator.go
Expand Up @@ -9,6 +9,7 @@ import (
)

const (
// QRSize indicates the size of the generated image containing the QR code.
QRSize = 256
)

Expand Down
1 change: 1 addition & 0 deletions config/algorithm.go
Expand Up @@ -7,6 +7,7 @@ import (
"hash"
)

// HmacAlgorithm type describes the supported hash algorithms for usage in OTP generation.
type HmacAlgorithm int

const (
Expand Down
4 changes: 4 additions & 0 deletions config/length.go
Expand Up @@ -6,6 +6,7 @@ import (
"strconv"
)

// Length type describes the recommended OTP lengths.
type Length int

// Supported length to the OTP generated using HOTP or TOTP.
Expand All @@ -20,15 +21,18 @@ const (
Length8
)

// Truncate will cut the provided number to fit the Length.
func (l Length) Truncate(number int) int {
return number % int(math.Pow10(int(l)))
}

// LeftPad adds extra zeroes to the left of the number to complete the Length.
func (l Length) LeftPad(number int) string {
format := "%0" + strconv.Itoa(int(l)) + "d"
return fmt.Sprintf(format, number)
}

// String converts the Length into a string.
func (l Length) String() string {
return strconv.Itoa(int(l))
}
1 change: 1 addition & 0 deletions hotp.go
Expand Up @@ -97,6 +97,7 @@ func (h *HOTP) KeyUri(accountName, issuer string) *authenticator.KeyUri {
}
}

// AsUrlValues returns the HOTP parameters represented as url.Values.
func (h *HOTP) AsUrlValues(issuer string) url.Values {
params := url.Values{}
params.Add("secret", h.Key)
Expand Down
1 change: 1 addition & 0 deletions totp.go
Expand Up @@ -102,6 +102,7 @@ func (t *TOTP) KeyUri(accountName, issuer string) *authenticator.KeyUri {
}
}

// AsUrlValues returns the TOTP parameters represented as url.Values.
func (t *TOTP) AsUrlValues(issuer string) url.Values {
params := url.Values{}
params.Add("secret", t.Key)
Expand Down

0 comments on commit bcead87

Please sign in to comment.