master
Raw Download raw file
 1package main
 2
 3//import "encoding/hex"
 4//import "math"
 5import "github.com/bryfry/ltcodes"
 6import "math/rand"
 7import "fmt"
 8import "time"
 9
10func main() {
11	rand.Seed(time.Now().UTC().UnixNano())
12	block_len := 15
13	test_msg := []byte("this is a test, this is only a test. Drop the beat!")
14	//fmt.Println(test_msg)
15	packets := make(chan ltcodes.Packet, 100)
16	decodeDone := make(chan bool)
17
18	// emit packets
19	go ltcodes.Encode(packets, test_msg, block_len)
20	go ltcodes.Decode(packets, decodeDone)
21	for {
22		select {
23		case <-decodeDone:
24			fmt.Println("Decode complete!")
25			return
26		}
27	}
28	close(packets)
29
30	// move to test
31	/*debug_xor := false
32	if debug_xor {
33		b1 := []byte("WhatAmIDoingHere?")
34		b2 := []byte("thisisjustatest !")
35		b3 := []byte("omg, there's more")
36		fmt.Println(hex.EncodeToString(xorBytes(b1, b2, b1, b2)))
37		fmt.Println(hex.EncodeToString([]byte(b1)))
38		fmt.Println(hex.EncodeToString(xorBytes(b1, b2, b3)))
39		fmt.Println(hex.EncodeToString(xorBytes(b1, b1)))   // expect all 00's
40		fmt.Println(string(xorBytes(b1, b2, b1))[:len(b1)]) // expect b2
41		b123 := [][]byte{b1, b2, b3}
42		b11 := [][]byte{b1, b1}
43		b121 := [][]byte{b1, b2, b1}
44		b1only := [][]byte{b1}
45		fmt.Println(hex.EncodeToString(xorBytes(b123...))) // expect same an non 2d slice array
46		fmt.Println(hex.EncodeToString(xorBytes(b11...)))  // expect all 00's
47		fmt.Println(string(xorBytes(b121...))[:len(b1)])   // expect b2
48		fmt.Println(string(xorBytes(b1only...))[:len(b1)]) // expect b1
49	}*/
50}