-
Notifications
You must be signed in to change notification settings - Fork 67
Open
Description
So, yeah. Validate returns Tokens mismatch. I can't seem to understand why ://
package main
import (
// "crypto"
b64 "encoding/base64"
"fmt"
"github.com/sec51/twofactor"
)
func main() {
// otpauth://totp/Cryptoapl:somemeails@gmail.com?secret=JEAM3MSPDPI5TLWDM4DEE4OCYDRVPSXY&issuer=Cryptoapl:karlis
issuer := "somesite"
// otp, err := twofactor.NewTOTP("i1nfo@somethingstuff.com", issuer, crypto.SHA1, 8)
// if err != nil {
// fmt.Println(err)
// return
// }
//
// bytes, err := otp.ToBytes()
// if err != nil {
// fmt.Println(err)
// return
// }
// bytesToString := string(bytes)
// base64EncodedBytes := b64.StdEncoding.EncodeToString([]byte(bytesToString))
// fmt.Println(base64EncodedBytes)
stringOfBytes, _ := b64.StdEncoding.DecodeString("oQAAAAAAAACcALyxTRxmg1YFxKYPcgR4s/e+K/mqlC6M92BekB51Wor/tdD1Q3/pj2RxUmpNzU79P65u2Oefj+lPgHBixKvWEWwLgH22nM/zo9SCf5umOn2txUrsfJPPzQSmG1SO3HFoSFkKvMMR7brDuHn53bDTS1l5+VeoR/QGrugglt8w8jcOOaDHGxahaZM9LmhBBlubT+P7cP5ndUA=")
stringToBytes := []byte(stringOfBytes)
otpTwo, err := twofactor.TOTPFromBytes(stringToBytes, issuer)
if err != nil {
fmt.Println(err)
return
}
// fmt.Println(otp.Secret())
fmt.Println(otpTwo.Secret())
authCode := "911849"
err = otpTwo.Validate(authCode)
if err != nil {
fmt.Println(err)
return
}
fmt.Println("Successful Authorisation!")
return
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels