-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathdll_test.go
71 lines (64 loc) · 1.81 KB
/
dll_test.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
package main
import (
"encoding/hex"
"fmt"
. "github.com/ying32/govcl/vcl"
"syscall"
"testing"
"unsafe"
)
var (
c_project = syscall.NewLazyDLL("./d.dll")
cDecodeStream_uEDCode = c_project.NewProc("cDecodeStream_uEDCode")
cEncodeStream_uEDCode = c_project.NewProc("cEncodeStream_uEDCode")
)
func EncodeStream_uEDCode(_in []byte, _key []byte) ([]byte, error) {
instm := NewMemoryStreamFromBytes(_in)
defer instm.Free()
outstm := NewMemoryStream()
defer outstm.Free()
cEncodeStream_uEDCode.Call(
uintptr(unsafe.Pointer(instm.Instance())),
uintptr(unsafe.Pointer(outstm.Instance())),
uintptr(unsafe.Pointer(&_key[0])),
)
_, r := outstm.Read(int32(outstm.Size()))
return r, nil
}
func DecodeStream_uEDCode(_in []byte, _key []byte) ([]byte, error) {
instm := NewMemoryStreamFromBytes(_in)
defer instm.Free()
outstm := NewMemoryStream()
defer outstm.Free()
cDecodeStream_uEDCode.Call(
uintptr(unsafe.Pointer(instm.Instance())),
uintptr(unsafe.Pointer(outstm.Instance())),
uintptr(unsafe.Pointer(&_key[0])),
)
_, r := outstm.Read(int32(outstm.Size()))
return r, nil
}
func Test_x(t *testing.T) {
//_path := "C:\\MirServer\\Mir200\\M2Project_Y.m2project"
//btm2project, err := ioutil.ReadFile(_path)
//if err != nil {
// return err
//}
key := []byte("964CF629-E9EC-47B8-AAFE-39172793BEB4-D89A1212-DB56-4858-9ADE-CF19A782E5A3-0B92A08-3578-49B7-BDF6-21B73AC5D9E5\x00")
encbt, err := hex.DecodeString("b0b4815d61eb7b8197889f")
//encbt,err:=base.EncodeStream_uEDCode([]byte("111"),key)
if err != nil {
panic(err)
}
fmt.Println(hex.EncodeToString((encbt)))
dbtstream, err := DecodeStream_uEDCode(encbt, key)
if err != nil {
panic(err)
}
fmt.Println(string(dbtstream))
dbtstream1, err := DecodeStream_uEDCode(encbt, key)
if err != nil {
panic(err)
}
fmt.Println(string(dbtstream1))
}