encryption + helpers + contact card compression + server routing start
This commit is contained in:
@ -1,6 +1,8 @@
|
||||
package meowlib
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"compress/gzip"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"image"
|
||||
@ -27,6 +29,31 @@ func (Contact *ContactCard) AddUrls(urls []string) {
|
||||
}
|
||||
}
|
||||
|
||||
func (contact *ContactCard) Serialize() ([]byte, error) {
|
||||
out, err := proto.Marshal(contact)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (contact *ContactCard) Compress() ([]byte, error) {
|
||||
out, err := contact.Serialize()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var b bytes.Buffer
|
||||
gz := gzip.NewWriter(&b)
|
||||
if _, err := gz.Write(out); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
if err := gz.Close(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
fmt.Println(b.Bytes())
|
||||
return b.Bytes(), nil
|
||||
}
|
||||
|
||||
func (contact *ContactCard) WritePng(filename string) {
|
||||
out, err := proto.Marshal(contact)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user