gmessages/libgm/qr.go

25 lines
582 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-07-15 13:25:54 +00:00
"google.golang.org/protobuf/proto"
2023-06-30 09:54:08 +00:00
"go.mau.fi/mautrix-gmessages/libgm/binary"
"go.mau.fi/mautrix-gmessages/libgm/util"
)
2023-07-16 12:55:30 +00:00
func (c *Client) GenerateQRCodeData(pairingKey []byte) (string, error) {
2023-07-15 13:25:54 +00:00
urlData := &binary.URLData{
2023-07-16 12:55:30 +00:00
PairingKey: pairingKey,
AESKey: c.AuthData.RequestCrypto.AESKey,
HMACKey: c.AuthData.RequestCrypto.HMACKey,
2023-06-30 09:54:08 +00:00
}
2023-07-15 13:25:54 +00:00
encodedURLData, err := proto.Marshal(urlData)
2023-06-30 09:54:08 +00:00
if err != nil {
return "", err
}
2023-07-15 13:25:54 +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
}