package web import ( "fmt" "io" "net/http" "strings" ) // FetchCommonWords fetches 10,000 common words from a wordlist func FetchCommonWords() ([]string, error) { // Create a GET request to Github wordlist resp, err := http.Get("https://raw.githubusercontent.com/first20hours/google-10000-english/refs/heads/master/google-10000-english-no-swears.txt") if err != nil { return nil, fmt.Errorf("failed to fetch URL: %v", err) } // Close body at end to avoid memory leaks defer resp.Body.Close() // Read response and parse into string bytes, err := io.ReadAll(resp.Body) if err != nil { return nil, fmt.Errorf("error reading response body: %v", err) } // Split response into list wordList := strings.Split(string(bytes), "\n") return wordList, nil } // FetchCommonPasswords fetches commonly used passwords from Github func FetchCommonPasswords() ([]string, error) { // Create GET request to Github for common password list resp, err := http.Get("https://raw.githubusercontent.com/AnandJogawade/Top-common-passwords/refs/heads/main/Top-common-passwords.v1.txt") if err != nil { return nil, fmt.Errorf("failed to fetch password list from Github: %v", err) } // Parse response into string bytes, err := io.ReadAll(resp.Body) if err != nil { return nil, fmt.Errorf("failed to parse response body") } // Split bytes into list passwordList := strings.Split(string(bytes), "\n") return passwordList, nil }