README.md in pwned-2.0.2 vs README.md in pwned-2.1.0

- old
+ new

@@ -2,26 +2,34 @@ An easy, Ruby way to use the Pwned Passwords API. [![Gem Version](https://badge.fury.io/rb/pwned.svg)](https://rubygems.org/gems/pwned) [![Build Status](https://travis-ci.org/philnash/pwned.svg?branch=master)](https://travis-ci.org/philnash/pwned) [![Maintainability](https://codeclimate.com/github/philnash/pwned/badges/gpa.svg)](https://codeclimate.com/github/philnash/pwned/maintainability) [![Inline docs](https://inch-ci.org/github/philnash/pwned.svg?branch=master)](https://inch-ci.org/github/philnash/pwned) -[API docs](https://philnash.github.io/pwned/) | [GitHub repo](https://github.com/philnash/pwned) +[API docs](https://www.rubydoc.info/gems/pwned) | [GitHub repo](https://github.com/philnash/pwned) ## Table of Contents -* [About](#about) -* [Installation](#installation) -* [Usage](#usage) - * [Plain Ruby](#plain-ruby) - * [Rails (ActiveRecord)](#activerecord-validator) - * [Devise](#devise) - * [Command line](#command-line) -* [How Pwned is Pi?](#how-pwned-is-pi) -* [Development](#development) -* [Contributing](#contributing) -* [License](#license) -* [Code of Conduct](#code-of-conduct) +- [Pwned](#pwned) + - [Table of Contents](#table-of-contents) + - [About](#about) + - [Installation](#installation) + - [Usage](#usage) + - [Plain Ruby](#plain-ruby) + - [Advanced](#advanced) + - [ActiveRecord Validator](#activerecord-validator) + - [I18n](#i18n) + - [Threshold](#threshold) + - [Network Error Handling](#network-error-handling) + - [Custom Request Options](#custom-request-options) + - [Using Asynchronously](#using-asynchronously) + - [Devise](#devise) + - [Command line](#command-line) + - [How Pwned is Pi?](#how-pwned-is-pi) + - [Development](#development) + - [Contributing](#contributing) + - [License](#license) + - [Code of Conduct](#code-of-conduct) ## About Troy Hunt's [Pwned Passwords API V2](https://haveibeenpwned.com/API/v2#PwnedPasswords) allows you to check if a password has been found in any of the huge data breaches. @@ -176,9 +184,20 @@ ```ruby validates :password, not_pwned: { request_options: { read_timeout: 5, open_timeout: 1, headers: { "User-Agent" => "Super fun user agent" } } } +``` + +### Using Asynchronously + +You may have a use case for hashing the password in advance, and then making the call to the Pwned api later +(for example if you want to enqueue a job without storing the plaintext password): + +```ruby +hashed_password = Pwned.hash_password(password) +# some time later +Pwned::HashPassword.new(hashed_password, request_options).pwned? ``` ### Devise If you are using Devise I recommend you use the [devise-pwned_password extension](https://github.com/michaelbanfield/devise-pwned_password) which is now powered by this gem.