-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathint_cipher_test.go
102 lines (87 loc) · 1.63 KB
/
int_cipher_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
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
package int_cipher
import (
"testing"
)
var KEY string = "abc"
func Test_int2bytes(t *testing.T) {
a := int2bytes(1000, 2)
if a[1] != 0xE8 || a[0] != 0x03 {
t.Fail()
}
}
func Test_bytes2int(t *testing.T) {
a := bytes2int([]byte{0x03, 0xE8})
if a != 1000 {
t.Fail()
}
}
func Test_Encrypt(t *testing.T) {
a := Encrypt(1, KEY)
b := Encrypt(3449674024, KEY)
if a != 3449674024 || b != 1 {
t.Fail()
}
}
func Test_Encrypt8(t *testing.T) {
a := Encrypt8(1, KEY)
b := Encrypt8(204, KEY)
if a != 204 || b != 1 {
t.Fail()
}
}
func Test_Encrypt16(t *testing.T) {
a := Encrypt16(1, KEY)
b := Encrypt16(52636, KEY)
if a != 52636 || b != 1 {
t.Fail()
}
}
func Test_Encrypt32(t *testing.T) {
a := Encrypt32(1, KEY)
b := Encrypt32(3449674024, KEY)
if a != 3449674024 || b != 1 {
t.Fail()
}
}
func Test_Encrypt64(t *testing.T) {
a := Encrypt64(1, KEY)
b := Encrypt64(14816237120726756722, KEY)
if a != 14816237120726756722 || b != 1 {
t.Fail()
}
}
func Test_Decrypt(t *testing.T) {
a := Decrypt8(1, KEY)
b := Decrypt8(204, KEY)
if a != 204 || b != 1 {
t.Fail()
}
}
func Test_Decrypt8(t *testing.T) {
a := Encrypt8(1, KEY)
b := Encrypt8(204, KEY)
if a != 204 || b != 1 {
t.Fail()
}
}
func Test_Decrypt16(t *testing.T) {
a := Encrypt16(1, KEY)
b := Encrypt16(52636, KEY)
if a != 52636 || b != 1 {
t.Fail()
}
}
func Test_Decrypt32(t *testing.T) {
a := Encrypt32(1, KEY)
b := Encrypt32(3449674024, KEY)
if a != 3449674024 || b != 1 {
t.Fail()
}
}
func Test_Decrypt64(t *testing.T) {
a := Encrypt64(1, KEY)
b := Encrypt64(14816237120726756722, KEY)
if a != 14816237120726756722 || b != 1 {
t.Fail()
}
}