pwned-passwords: Index | Files

package hibp

import ""


Package Files

cache.go hibp.go pwned.go

type CacheService Uses

type CacheService service

CacheService handles in-memory caching of our hash/compromised pairs.

func (*CacheService) Expire Uses

func (s *CacheService) Expire(hash string)

Expire will expire the cache for a given hash.

func (*CacheService) ExpireAll Uses

func (s *CacheService) ExpireAll()

ExpireAll will expire all cache.

func (*CacheService) Get Uses

func (s *CacheService) Get(hash string) *PwnedStore

Get will return our stored in-memory hash/compromised pairs, if we have them.

func (*CacheService) IsExpired Uses

func (s *CacheService) IsExpired(hash string) bool

IsExpired checks if we have cached hash and that it isn't expired.

func (*CacheService) Store Uses

func (s *CacheService) Store(hash string, compromised bool)

Store will save our hash/compromised pairs to a PwnedStore.

type Client Uses

type Client struct {
    AppID      string
    UserAgent  string
    BackendURL *url.URL

    // Services used for communicating with the API.
    Pwned *PwnedService
    Cache *CacheService
    // contains filtered or unexported fields

Client holds a connection to the HIBP API.

func NewClient Uses

func NewClient() *Client

NewClient creates a new Client with the appropriate connection details and services used for communicating with the API.

func (*Client) Do Uses

func (c *Client) Do(req *http.Request) ([]string, error)

Do sends an API request and returns the API response.

func (*Client) NewRequest Uses

func (c *Client) NewRequest(method, urlPath string, body interface{}) (*http.Request, error)

NewRequest creates an API request. A relative URL can be provided in urlPath, which will be resolved to the BackendURL of the Client.

type PwnedService Uses

type PwnedService service

PwnedService handles retrieving pwned hashes from in-memory cache or by fetching fresh results.

func (*PwnedService) Compromised Uses

func (s *PwnedService) Compromised(value string) (bool, error)

Compromised will build and execute a request to HIBP to check to see if the passed value is compromised or not.

type PwnedStore Uses

type PwnedStore struct {
    Hash        string     `json:"hash"`
    Compromised bool       `json:"compromised"`
    UpdatedAt   *time.Time `json:"updated_at"`

PwnedStore holds our pwned password hashes and compromised status.

Package hibp imports 12 packages (graph). Updated 2018-03-12. Refresh now. Tools for package owners.