From bcead871dd3a02fb51505f07f20d556f12181b41 Mon Sep 17 00:00:00 2001 From: Jose Torres Date: Wed, 2 Sep 2020 16:45:19 -0500 Subject: [PATCH] Update go docs. --- authenticator/authenticator.go | 1 + config/algorithm.go | 1 + config/length.go | 4 ++++ hotp.go | 1 + totp.go | 1 + 5 files changed, 8 insertions(+) diff --git a/authenticator/authenticator.go b/authenticator/authenticator.go index 42b2439..4d46902 100644 --- a/authenticator/authenticator.go +++ b/authenticator/authenticator.go @@ -9,6 +9,7 @@ import ( ) const ( + // QRSize indicates the size of the generated image containing the QR code. QRSize = 256 ) diff --git a/config/algorithm.go b/config/algorithm.go index b543480..cc3ed1d 100644 --- a/config/algorithm.go +++ b/config/algorithm.go @@ -7,6 +7,7 @@ import ( "hash" ) +// HmacAlgorithm type describes the supported hash algorithms for usage in OTP generation. type HmacAlgorithm int const ( diff --git a/config/length.go b/config/length.go index f429073..42ba1a8 100644 --- a/config/length.go +++ b/config/length.go @@ -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. @@ -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)) } diff --git a/hotp.go b/hotp.go index 685d136..756f5ce 100644 --- a/hotp.go +++ b/hotp.go @@ -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) diff --git a/totp.go b/totp.go index f0526b3..e8420c7 100644 --- a/totp.go +++ b/totp.go @@ -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)