2023-06-30 09:54:08 +00:00
|
|
|
package crypto
|
|
|
|
|
|
|
|
import (
|
2023-06-30 10:48:52 +00:00
|
|
|
"encoding/base64"
|
|
|
|
|
2023-06-30 09:54:08 +00:00
|
|
|
"google.golang.org/protobuf/proto"
|
|
|
|
|
|
|
|
"go.mau.fi/mautrix-gmessages/libgm/binary"
|
|
|
|
)
|
|
|
|
|
|
|
|
func DecodeAndEncodeB64(data string, msg proto.Message) error {
|
2023-06-30 10:48:52 +00:00
|
|
|
decodedBytes, err := base64.StdEncoding.DecodeString(data)
|
2023-06-30 09:54:08 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
err = binary.DecodeProtoMessage(decodedBytes, msg)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|