summary refs log tree commit diff stats
path: root/hibp/pwned.go
diff options
context:
space:
mode:
authorAndinus <andinus@nand.sh>2021-04-13 13:52:09 +0530
committerAndinus <andinus@nand.sh>2021-04-13 13:52:09 +0530
commit863b5301e2d2c75683086a608ebdf8f497133b94 (patch)
treefc7a07bac513abbd874102fa2e95b9dd0b00d415 /hibp/pwned.go
parent12fdf3632824a3ffea9f8dfc9249cb7a27e6a2c8 (diff)
downloadorion-863b5301e2d2c75683086a608ebdf8f497133b94.tar.gz
Re-initialize project for Raku port
Diffstat (limited to 'hibp/pwned.go')
-rw-r--r--hibp/pwned.go40
1 files changed, 0 insertions, 40 deletions
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, ""
-}