MCPcopy Create free account
hub / github.com/TideSec/GoBypassAV / encode

Function encode

Encryption/Bagua_code/main.go:44–64  ·  view source on GitHub ↗
(src []byte)

Source from the content-addressed store, hash-verified

42}
43
44func encode(src []byte) string {
45 bs := make([]int, len(src)*8)
46 bl := len(bs)
47 for k, v := range src {
48 byteTo2(int(v), bs[k*8:k*8+8])
49 }
50
51 buf := make([]string, (bl+2)/3)
52 for i := 0; i*3+2 < len(bs); i++ {
53 buf[i] = m1[bs[i*3]<<2+bs[i*3+1]<<1+bs[i*3+2]]
54 }
55
56 switch bl % 3 {
57 case 1:
58 buf[(bl+2)/3-1] = m1[bs[bl-1]<<2]
59 case 2:
60 buf[(bl+2)/3-1] = m1[bs[bl-2]<<2+bs[bl-1]<<1]
61 }
62
63 return strings.Join(buf, "")
64}
65
66func decode(s string) ([]byte, error) {
67 if s == "" {

Callers 1

Bagua_enFunction · 0.85

Calls 1

byteTo2Function · 0.85

Tested by

no test coverage detected