~poldi1405/go-yenc

ref: db8820d1a641a361e795ea23f26415f1c5eec62d go-yenc/splitting.go -rw-r--r-- 317 bytes
db8820d1 — Moritz Poldrack started work on encoder 11 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package yenc

func getParts(in *[]byte) *[][8]byte {
	var parts [][8]byte

	var part [8]byte
	var i int

	for _, b := range *in {
		part[i] = b
		i++

		if i == 8 {
			parts = append(parts, part)
			i = 0
		}
	}

	if i != 0 {
		for i < 8 {
			part[i] = 0
			i++
		}
		parts = append(parts, part)
	}

	return &parts
}