gmessages/libgm/qr.go
2023-07-15 16:37:44 +03:00

24 lines
569 B
Go

package libgm
import (
"encoding/base64"
"google.golang.org/protobuf/proto"
"go.mau.fi/mautrix-gmessages/libgm/binary"
"go.mau.fi/mautrix-gmessages/libgm/util"
)
func (p *Pairer) GenerateQRCodeData() (string, error) {
urlData := &binary.URLData{
PairingKey: p.pairingKey,
AESKey: p.client.authData.Cryptor.AESKey,
HMACKey: p.client.authData.Cryptor.HMACKey,
}
encodedURLData, err := proto.Marshal(urlData)
if err != nil {
return "", err
}
cData := base64.StdEncoding.EncodeToString(encodedURLData)
return util.QRCodeURLBase + cData, nil
}