forked from rkbalgi/libiso
/
scratchpad.go
112 lines (91 loc) · 2.27 KB
/
scratchpad.go
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
package main
//import hexutils "github.com/rkbalgi/utils"
import "github.com/rkbalgi/go/crypto"
import (
"bytes"
"encoding/hex"
"fmt"
"github.com/rkbalgi/go/utils"
"reflect"
"sync"
//"os"
// "strings"
//"strconv"
//"bufio"
// "io"
)
type CommandHeader struct {
Header string `size:"12"`
CommandName string `size:"2"`
MacData []byte `size:"4"`
}
var letterMap map[string]int
func letterSum(month string) int {
sum := 0
for i := 0; i < len(month); i++ {
sum += letterMap[month[i:i+1]]
}
return sum
}
func main() {
fmt.Println("Hello World")
letterMap = make(map[string]int, 26)
tmp := "abcdefghijklmnopqrstuvwxyz"
for i := 1; i < 27; i++ {
letterMap[tmp[i-1:i]] = i
}
fmt.Println("january ", letterSum("s"))
cmd := "NC"
fmt.Println(hex.EncodeToString([]byte(cmd)))
what_type := [...]int{1, 2, 3}
fmt.Println(reflect.TypeOf(what_type).Kind().String())
//fmt.Printf("%s-%s\n",command_header.Header,command_header.CommandName)
//fmt.Println(command_header)
//os.Exit(0);
var testKey []byte = []byte("helloworld111112") //67876543")
testData, _ := hex.DecodeString("3657f432e456feda01")
fmt.Printf("Key: %s Data: %s\n", hex.EncodeToString(testKey), hex.EncodeToString(testData))
encryptedData, err := crypto.EncryptTripleDesEde2(testKey, testData, crypto.Iso9797M2Padding)
fmt.Println(utils.HexToString(encryptedData), " - ")
decryptedData, err := crypto.DecryptTripleDesEde2(testKey, encryptedData, crypto.Iso9797M2Padding)
if bytes.Equal(testData, decryptedData) {
fmt.Println("Test OK")
} else {
fmt.Print("Test Failed")
}
if err == nil {
fmt.Println(utils.HexToString(encryptedData), " - ", utils.HexToString(decryptedData))
//fmt.Println(crypto.Iso9797M1Padding," ", crypto.Iso9797M2Padding)
}
fmt.Printf("%08b\n", 10)
var goGrp *sync.WaitGroup = new(sync.WaitGroup)
go func() {
fmt.Println("Hello World")
goGrp.Done()
}()
//goGrp.Add(1);
goGrp.Wait()
fmt.Println(crypto.RotN(3, "xyzragha"))
/*var arr = [10]uint32{
1,
2,
3,
4,
5,
6,
7,
8,
9,
10}
defer my_func(10)
fmt.Printf("%T %d \n", arr, cap(arr))
var total float32 = 0
var i int
var val uint32
for i, val = range arr {
fmt.Print(i, val, "\n")
total += float32(val)
}
avg := total / float32(len(arr))
fmt.Printf("%T - %f\n", avg, avg)*/
}