pquerna / otp

TOTP library for Go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Must use AlgorithmSHA1 with iOS version of Google Authenticator

yghazi opened this issue · comments

        key,_ := totp.Generate(totp.GenerateOpts{ 
              AccountName: "XYZ Test", 
              Issuer: "some.domain.com", 
              Algorithm: otp.AlgorithmSHA512, 
        })
        
        var buff bytes.Buffer
	img, _ := key.Image(256,256)
	f, _ := os.Create("test.html")
	png.Encode(&buff, img)
	encodedString := base64.StdEncoding.EncodeToString(buff.Bytes())
	htmlImage := "<img src=\"data:image/png;base64," + encodedString + "\" />"
	l, err := f.WriteString(htmlImage)
	if err != nil {
		log.Println(err)
	}

The resultant test.html shows a QR code that provides correct codes when scanned with Google Authenticator on Android, but not on iPhone.

Try using Algorithm: otp.AlgorithmSHA1 - I think the iOS version supports less algorithms for the TOTP.

hi @yghazi @pquerna I got same issue today when using Algo SHA512 on Iphone google authenticator.
Switch to SHA1, it works.

(SHA512 still works with Iphone Authen and Android Google Authenticator)

So I think best way to support Iphone GG authenticator is switch it to SHA1