diff --git a/totp.go b/totp.go index 10a2876..c3d6f3f 100644 --- a/totp.go +++ b/totp.go @@ -123,12 +123,11 @@ func totpFromURL(u *url.URL) (*TOTP, string, error) { var algo = crypto.SHA1 if algorithm := v.Get("algorithm"); algorithm != "" { - switch { - case algorithm == "SHA256": + if strings.EqualFold(algorithm, "SHA256") { algo = crypto.SHA256 - case algorithm == "SHA512": + } else if strings.EqualFold(algorithm, "SHA512") { algo = crypto.SHA512 - case algorithm != "SHA1": + } else if !strings.EqualFold(algorithm, "SHA1") { return nil, "", ErrInvalidAlgo } }