Esempio n. 1
0
func TestEncodeReport(t *testing.T) {
	const rep = "Hello World, ···"
	key := crypto.GenerateCipherMsgKey()
	buf, err := EncodeReport([]byte(rep), key.PubKey())
	if err != nil {
		t.Fatalf("encode: %s", err)
	}
	fmt.Printf("compressed size = %d\n", len(buf))
	rep2, err := DecodeReport(buf, 400, key)
	if err != nil {
		t.Fatalf("decode: %s", err)
	}
	rep1 := []byte(rep)
	if len(rep2) != len(rep1) {
		t.Fatalf("rep len")
	}
	for i := 0; i < len(rep1); i++ {
		if rep1[i] != rep2[i] {
			t.Errorf("byte mismatch at pos %d", i)
		}
	}
}
Esempio n. 2
0
func main() {
	key := crypto.GenerateCipherMsgKey()
	fmt.Printf("PRIVATE:\n%s\nPUBLIC:\n%s\n", key.String(), key.PubKey().String())
}