Skip to content

Commit

Permalink
❤️ Replacing GoMutation with generator.py
Browse files Browse the repository at this point in the history
  • Loading branch information
julioliraup committed Mar 29, 2020
1 parent 47b621b commit 5e355a6
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 126 deletions.
118 changes: 118 additions & 0 deletions modules/GoMutation.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
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").Replace(word)
}
func count1to8(word string) []string {
list := []string {word}
for i := 0; 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 := 2020; 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))
finalContent = append(content, combine(content)...)

// Running functions for make wordlist
for _, word := range content {
finalContent = append(finalContent, leet(word))
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)
if numberWrote < 1 {
fmt.Println("1b?")
}
}
56 changes: 0 additions & 56 deletions modules/generator.py

This file was deleted.

70 changes: 0 additions & 70 deletions modules/permutations/main.py

This file was deleted.

0 comments on commit 5e355a6

Please sign in to comment.