github.com/egonelbre/exp@v0.0.0-20240430123955-ed1d3aa93911/brutecheck/utils.go (about) 1 package main 2 3 // keywordBounds returns minimum and maximum keyword length. 4 func keywordBounds(keywords []string) (min, max int) { 5 min, max = len(keywords[0]), len(keywords[0]) 6 for _, keyword := range keywords[1:] { 7 n := len(keyword) 8 if n < min { 9 min = n 10 } 11 if n > max { 12 max = n 13 } 14 } 15 return min, max 16 } 17 18 // findUniqueChar finds first unique character from names that is safe to check. 19 // 20 // returns -1 when one does not exist. 21 func findUniqueChar(names []string) int { 22 minlen, _ := keywordBounds(names) 23 next: 24 for i := 0; i < minlen; i++ { 25 var seen [256]bool 26 for _, name := range names { 27 if seen[name[i]] { 28 continue next 29 } 30 seen[name[i]] = true 31 } 32 return i 33 } 34 return -1 35 }