gmessages/libgm/qr.go

23 lines
540 B
Go
Raw Normal View History

2023-06-30 11:05:33 +00:00
package libgm
2023-06-30 09:54:08 +00:00
import (
2023-06-30 10:48:52 +00:00
"encoding/base64"
2023-06-30 09:54:08 +00:00
"go.mau.fi/mautrix-gmessages/libgm/binary"
"go.mau.fi/mautrix-gmessages/libgm/util"
)
func (p *Pairer) GenerateQRCodeData() (string, error) {
urlData := &binary.UrlData{
2023-06-30 13:26:46 +00:00
PairingKey: p.pairingKey,
AESCTR256Key: p.client.cryptor.AESCTR256Key,
SHA256Key: p.client.cryptor.SHA256Key,
2023-06-30 09:54:08 +00:00
}
encodedUrlData, err := binary.EncodeProtoMessage(urlData)
if err != nil {
return "", err
}
2023-06-30 10:48:52 +00:00
cData := base64.StdEncoding.EncodeToString(encodedUrlData)
2023-06-30 13:31:35 +00:00
return util.QRCodeURLBase + cData, nil
2023-06-30 09:54:08 +00:00
}