openvpn-mgt/vendor/github.com/mattevans/pwned-passwords
Xavier Henner 68de442333 Add logging, including the json one
get infos from I've been pwned and the API on install.dm.gg/vpn-log.php

and send mail if there is anything strange
2019-07-10 17:47:43 +02:00
..
.travis.yml Add logging, including the json one 2019-07-10 17:47:43 +02:00
LICENSE Add logging, including the json one 2019-07-10 17:47:43 +02:00
README.md Add logging, including the json one 2019-07-10 17:47:43 +02:00
cache.go Add logging, including the json one 2019-07-10 17:47:43 +02:00
hibp.go Add logging, including the json one 2019-07-10 17:47:43 +02:00
pwned.go Add logging, including the json one 2019-07-10 17:47:43 +02:00

README.md

pwned-passwords

GoDoc Build Status Go Report Card license

A simple Go client library for checking compromised passwords against HIBP Pwned Passwords.

Upon request, results will be cached (in-memory), keyed by hash. With a two hour expiry window, subsequent requests will use cached data or fetch fresh data accordingly.

Installation

go get -u github.com/mattevans/pwned-passwords

Usage

package main

import (
        "fmt"
	hibp "github.com/mattevans/pwned-passwords"
	"os"
)

func main() {
  // Init a client.
  client := hibp.NewClient()

  // Check to see if your given string is compromised.
  pwned, err := client.Pwned.Compromised("string to check")
  if err != nil {
      fmt.Println("Pwned failed")
      os.Exit(1)
  }

  if pwned {
      // Oh dear!
      // You should avoid using that password
  } else {
     // Woo!
     // All clear!
  }
}

Expire in-memory cache

client.Cache.Expire(HASHED_VALUE)
client.Cache.ExpireAll()

Contributing

If you've found a bug or would like to contribute, please create an issue here on GitHub, or better yet fork the project and submit a pull request!