From 863b5301e2d2c75683086a608ebdf8f497133b94 Mon Sep 17 00:00:00 2001 From: Andinus Date: Tue, 13 Apr 2021 13:52:09 +0530 Subject: Re-initialize project for Raku port --- hibp/pwned.go | 40 ---------------------------------------- 1 file changed, 40 deletions(-) delete mode 100644 hibp/pwned.go (limited to 'hibp/pwned.go') diff --git a/hibp/pwned.go b/hibp/pwned.go deleted file mode 100644 index 57a1727..0000000 --- a/hibp/pwned.go +++ /dev/null @@ -1,40 +0,0 @@ -package hibp - -import ( - "fmt" - "strings" -) - -// GetPwned takes SHA-1 Hash as input & returns Pwned Passwords list -// returned by the Have I Been Pwned API -func GetPwned(hsh string) (map[string]string, error) { - api := "https://api.pwnedpasswords.com/range" - list := make(map[string]string) - - pfx := hsh[:5] - - reqApi := fmt.Sprintf("%s/%s", api, pfx) - body, err := reqHIBP(reqApi) - if err != nil { - return list, fmt.Errorf("reqHIBP failed\n%s", - err.Error()) - } - - for _, v := range strings.Split(body, "\r\n") { - s := strings.Split(v, ":") - list[s[0]] = s[1] - } - return list, err -} - -// ChkPwn takes list, hash as input & returns if the hash is in list, -// the frequency -func ChkPwn(list map[string]string, hsh string) (bool, string) { - sfx := hsh[5:] - for k, fq := range list { - if sfx == k { - return true, fq - } - } - return false, "" -} -- cgit 1.4.1-2-gfad0