Skip to content

Commit

Permalink
Change Period type to uint64 (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
cristaloleg authored Jun 28, 2024
1 parent 8f60c24 commit 30e46a0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion hotp.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func NewHOTP(cfg HOTPConfig) (*HOTP, error) {
func (h *HOTP) GenerateURL(account string, secret []byte) string {
v := url.Values{}
v.Set("algorithm", h.cfg.Algo.String())
v.Set("digits", atoi(h.cfg.Digits))
v.Set("digits", atoi(uint64(h.cfg.Digits)))
v.Set("issuer", h.cfg.Issuer)
v.Set("secret", b32Enc(secret))

Expand Down
4 changes: 2 additions & 2 deletions otp.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,6 @@ func b32Enc(src []byte) string {
return base32.StdEncoding.WithPadding(base32.NoPadding).EncodeToString(src)
}

func atoi(v uint) string {
return strconv.FormatUint(uint64(v), 10)
func atoi(v uint64) string {
return strconv.FormatUint(v, 10)
}
4 changes: 2 additions & 2 deletions totp.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type TOTPConfig struct {
Algo Algorithm
Digits uint
Issuer string
Period uint
Period uint64
Skew uint
}

Expand Down Expand Up @@ -61,7 +61,7 @@ func NewTOTP(cfg TOTPConfig) (*TOTP, error) {
func (t *TOTP) GenerateURL(account string, secret []byte) string {
v := url.Values{}
v.Set("algorithm", t.cfg.Algo.String())
v.Set("digits", atoi(t.cfg.Digits))
v.Set("digits", atoi(uint64(t.cfg.Digits)))
v.Set("issuer", t.cfg.Issuer)
v.Set("secret", b32Enc(secret))
v.Set("period", atoi(t.cfg.Period))
Expand Down

0 comments on commit 30e46a0

Please sign in to comment.