hibp

package module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 21, 2021 License: MIT Imports: 9 Imported by: 2

README

go-hibp - Simple go client for the HIBP API

Go Reference Go Report Card Build Status

Usage

Pwned Passwords API
package main

import (
	"fmt"
	"github.com/wneessen/go-hibp"
)

func main() {
	hc := New()
	m, _, err := hc.PwnedPassword.CheckPassword("test123")
	if err != nil {
		panic(err)
	}
	if m != nil && m.Count != 0 {
		fmt.Println("Your password was found in the pwned passwords DB")
    }
}

Documentation

Index

Constants

View Source
const Version = "0.1.1"

Version represents the version of this package

Variables

This section is empty.

Functions

This section is empty.

Types

type Client added in v0.1.1

type Client struct {
	PwnedPassword *PwnedPassword // Reference to the PwnedPassword API
	// contains filtered or unexported fields
}

Client is the HIBP client object

func New added in v0.1.1

func New(options ...Option) *Client

New creates and returns a new HIBP client object

func (*Client) HttpReq added in v0.1.1

func (c *Client) HttpReq(m, p string) (*http.Request, error)

HttpReq performs an HTTP request to the corresponding API

type Match added in v0.1.1

type Match struct {
	Hash  string
	Count int64
}

Match represents a match in the Pwned Passwords API

type Option added in v0.1.1

type Option func(*Client)

Option is a function that is used for grouping of Client options.

func WithApiKey added in v0.1.1

func WithApiKey(k string) Option

WithApiKey set the optional API key to the Client object

func WithHttpTimeout added in v0.1.1

func WithHttpTimeout(t time.Duration) Option

WithHttpTimeout overrides the default http client timeout

type PwnedPassword added in v0.1.1

type PwnedPassword struct {
	// contains filtered or unexported fields
}

PwnedPassword is a HIBP Pwned Passwords API client

func (*PwnedPassword) CheckPassword added in v0.1.1

func (p *PwnedPassword) CheckPassword(pw string) (*Match, *http.Response, error)

CheckPassword checks the Pwned Passwords database against a given password string

func (*PwnedPassword) CheckSHA1 added in v0.1.1

func (p *PwnedPassword) CheckSHA1(h string) (*Match, *http.Response, error)

CheckSHA1 checks the Pwned Passwords database against a given SHA1 checksum of a password

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL