-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
128 lines (117 loc) · 3.2 KB
/
main.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
package main
import (
"fmt"
"strings"
"io/ioutil"
"os"
"strconv"
)
// Check if err
func check(e error) {
if e != nil {
panic(e)
}
}
// Removing duplicated items
func unique(intSlice []string) []string {
keys := make(map[string]bool)
list := []string {}
for _, entry := range intSlice {
if _, value := keys[entry]; !value {
keys[entry] = true
list = append(list, entry)
}
}
return list
}
// Pure functions
func leet(word string) string {
return strings.NewReplacer("A","4", "E", "3", "I", "1", "O", "0", "S", "5", "T", "7", "B", "8",
"a","4", "e", "3", "i", "1", "o", "0", "s", "5", "t", "7", "b", "8").Replace(word)
}
func count1to8(word string) []string {
list := []string {word}
for i := 1; i < 9; i++ {
list = append(list,list[len(list)-1]+strconv.Itoa(i))
}
return list
}
func year90(word string) []string {
list := []string {word}
for i := 99; i > 89; i-- {
list = append(list,word+strconv.Itoa(i))
}
return list
}
func year2000(word string) []string {
list := []string {word}
for i := 2024; i > 1999; i-- {
list = append(list,word+strconv.Itoa(i))
}
return list
}
func swapCase(r rune) rune {
switch {
case 'a' <= r && r <= 'z':
return r - 'a' + 'A'
case 'A' <= r && r <= 'Z':
return r - 'A' + 'a'
default:
return r
}
}
func inverter(word string) string {
runes := []rune(string(word))
for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
runes[i], runes[j] = runes[j], runes[i]
}
return string(runes)
}
func mess(word string, allList []string) []string {
list := []string {}
for _, i := range allList {
list = append(list, word + i)
}
return list
}
func combine(allList []string) []string {
finalWords := []string {}
for _, i := range allList {
finalWords = append(finalWords, mess(i, allList)...)
}
return finalWords
}
func main() {
finalContent := []string {}
// Read base file
blob, err := ioutil.ReadFile(os.Args[1])
check(err)
content := strings.Fields(string(blob))
// Combinatory expression out context of loop. But work finalContent
finalContent = append(content, combine(content)...)
// Leet after input in loop
for _, word:= range finalContent {
content = append(finalContent, leet(word))
}
// Running functions for make wordlist
for _, word := range content {
finalContent = append(finalContent, count1to8(word)...)
finalContent = append(finalContent, year90(word)...)
finalContent = append(finalContent, year2000(word)...)
finalContent = append(finalContent, strings.ToUpper(word))
finalContent = append(finalContent, strings.ToLower(word))
finalContent = append(finalContent, strings.Map(swapCase, word))
finalContent = append(finalContent, inverter(word))
}
// Save data
file, errCreate := os.Create(os.Args[2])
check(errCreate)
defer file.Close()
data := []byte(strings.Join(unique(finalContent), "\n"))
numberWrote, errWrite := file.Write(data)
check(errWrite)
fmt.Printf("File saved in %s: %db\n", os.Args[2], numberWrote)
if numberWrote < 1 {
fmt.Println("1b?")
}
}