-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtripcode_test.go
91 lines (86 loc) · 2.17 KB
/
tripcode_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
package tripcode
import (
"testing"
)
func TestGenerateSalt(t *testing.T) {
cases := map[string]string{
"asd": "sd",
"adasd": "da",
"!@#$%^&*()": "G.",
"f}E": ".E",
"©": "H.",
"訛": "H.",
"'": "H.",
}
for pass, expected := range cases {
salt := generateSalt(pass)
if expected != salt {
t.Errorf("Expected \"%s\", got \"%s\"", expected, salt)
}
}
}
func TestSecureTripcode(t *testing.T) {
expect := "PqG4A0fkUs"
trip := SecureTripcode("pass", "salt")
if trip != expect {
t.Errorf("SecureTripcode: expected \"%s\", got \"%s\"", expect, trip)
}
}
func TestTripcode(t *testing.T) {
cases := map[string]string{
"asd": "TAPy3blMsc",
"adasd": "IOuORdzMKw",
"!@#$%^&*()": "BpZUCmJAIQ",
"f}E": "oUBoOTrysY",
"©": "", // Should be nothing?
"訛": "c8eDXvwFLQ",
"!": "KNs1o0VDv6",
"@": "z0MWdctOjE",
"#": "u2YjtUz8MU",
"$": "yflOPYrGcY",
"%": "1t98deumW.",
"^": "gBeeWo4hQg",
"&": "MhCJJ7GVT.",
"*": "o8gKYE6H8A",
"(": "SGn2Wwr9CY",
")": "E9k1wjKgHI",
"-": "tHbGiobWdM",
"_": "m3eoQIlU/U",
"=": "wmxP/NHJxA",
"+": "IHLbs/YhoA",
"[": "7h2f0/nQ3w",
"]": "rjM99frkZs",
"{": "odBt7a7lv6",
"}": "ATNP9hXHcg",
";": "zglc7ct1Ls",
":": ".BmRMKOub2",
"'": "8/08awL.AE",
"\"": "gt1azVccY2",
"<": "D1YGKrvmeg",
">": "afqVxck0Ts",
",": "YeQQgdCJE6",
".": "XONm83jaIU",
"\\": "9xUxYS2dlM",
"?": "cPUZU5OGFs",
" ": "wqLZLRuzPQ",
"ññññ": "",
"糯ォT弓(窶": "Pants.f1Fk",
}
for pass, expected := range cases {
trip := Tripcode(pass)
if expected != trip {
t.Errorf("Expected \"%s\", got \"%s\"", expected, trip)
}
}
}
func TestTripcodeOverflow(t *testing.T) {
pass := ""
for i := 0; i < 30000; i++ {
pass += string(rune(i))
}
expected := "Ggih.96XPU"
trip := Tripcode(pass)
if expected != trip {
t.Errorf("Expected \"%s\", got \"%s\"", expected, trip)
}
}