-
Notifications
You must be signed in to change notification settings - Fork 121
/
pwned.go
34 lines (28 loc) · 801 Bytes
/
pwned.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Made possible with help of go-pwnedpassword library (https://github.com/ecnepsnai/go-pwnedpassword)
package main
import (
"fmt"
"os"
"strings"
pwned "github.com/ecnepsnai/go-pwnedpassword"
)
func main() {
// get password
pass := os.Args[1:]
if len(pass) == 0 {
fmt.Println("usage go pwned.go [password]")
} else {
password := strings.Join(pass, "")
result, err := pwned.IsPwned(password)
if err != nil {
// Something went wrong (probably couldn't contact the pwned password API)
}
if !result.Pwned {
// Password hasn't been seen before. Doesn't mean it's safe, just lucky.
} else {
count := result.TimesObserved
fmt.Println("you password has been compromised and has been seen : ", count, "times")
// Password has been seen `count` times before.
}
}
}