From 5e98f0b9829d22e47ff566e8903dc4003f1da9fd Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Tue, 1 Oct 2019 21:20:37 +1000 Subject: [PATCH] Generate latest docs --- docs/NotPwnedValidator.html | 4 +- docs/Pwned.html | 6 +- docs/Pwned/Error.html | 4 +- docs/Pwned/Password.html | 4 +- docs/Pwned/TimeoutError.html | 4 +- docs/PwnedValidator.html | 4 +- docs/_index.html | 4 +- docs/file.README.html | 427 ++++++++++++++++++++-------------- docs/index.html | 427 ++++++++++++++++++++-------------- docs/top-level-namespace.html | 4 +- 10 files changed, 515 insertions(+), 373 deletions(-) diff --git a/docs/NotPwnedValidator.html b/docs/NotPwnedValidator.html index 032c81e..20ad130 100644 --- a/docs/NotPwnedValidator.html +++ b/docs/NotPwnedValidator.html @@ -484,9 +484,9 @@

diff --git a/docs/Pwned.html b/docs/Pwned.html index d47bb34..783eb34 100644 --- a/docs/Pwned.html +++ b/docs/Pwned.html @@ -130,7 +130,7 @@

-
"1.2.1"
+
"2.0.0"
@@ -511,9 +511,9 @@

diff --git a/docs/Pwned/Error.html b/docs/Pwned/Error.html index 6b7e274..ba94e46 100644 --- a/docs/Pwned/Error.html +++ b/docs/Pwned/Error.html @@ -139,9 +139,9 @@

Direct Known Subclasses

diff --git a/docs/Pwned/Password.html b/docs/Pwned/Password.html index 6533c18..7510562 100644 --- a/docs/Pwned/Password.html +++ b/docs/Pwned/Password.html @@ -926,9 +926,9 @@

diff --git a/docs/Pwned/TimeoutError.html b/docs/Pwned/TimeoutError.html index 02cde21..d0bf5ab 100644 --- a/docs/Pwned/TimeoutError.html +++ b/docs/Pwned/TimeoutError.html @@ -142,9 +142,9 @@

Overview

diff --git a/docs/PwnedValidator.html b/docs/PwnedValidator.html index 13443ed..db3478e 100644 --- a/docs/PwnedValidator.html +++ b/docs/PwnedValidator.html @@ -182,9 +182,9 @@

Methods inherited from - Generated on Mon Jul 29 14:27:46 2019 by + Generated on Tue Oct 1 21:19:37 2019 by yard - 0.9.20 (ruby-2.3.7). + 0.9.20 (ruby-2.5.5). diff --git a/docs/_index.html b/docs/_index.html index a8df15e..8eed93e 100644 --- a/docs/_index.html +++ b/docs/_index.html @@ -152,9 +152,9 @@

Namespace Listing A-Z

diff --git a/docs/file.README.html b/docs/file.README.html index 0fb63ed..97c219a 100644 --- a/docs/file.README.html +++ b/docs/file.README.html @@ -57,57 +57,80 @@
-

Pwned

+
+

Pwned

An easy, Ruby way to use the Pwned Passwords API.

-

Gem Version Build Status Maintainability Inline docs

- - - - - - - - -
API docsGitHub repo
- -

Table of Contents

- - - -

About

- -

Troy Hunt’s Pwned Passwords API V2 allows you to check if a password has been found in any of the huge data breaches.

- -

Pwned is a Ruby library to use the Pwned Passwords API’s k-Anonymity model to test a password against the API without sending the entire password to the service.

- -

The data from this API is provided by Have I been pwned?. Before using the API, please check the acceptable uses and license of the API.

- -

Here is a blog post I wrote on how to use this gem in your Ruby applications to make your users’ passwords better.

- -

Installation

- -

Add this line to your application’s Gemfile:

- -

ruby -gem 'pwned' -

+

+ +

API docs | GitHub repo

+ +

Table of Contents

+ + +

About

+ +

Troy Hunt's Pwned Passwords API +V2 allows you to check if a password has been found in any of the huge +data breaches.

+ +

Pwned is a Ruby library to use the Pwned Passwords API's +k-Anonymity +model to test a password against the API without sending the entire +password to the service.

+ +

The data from this API is provided by Have I been pwned?. Before using the +API, please check the acceptable uses +and license of the API.

+ +

Here is a blog post I wrote on how +to use this gem in your Ruby applications to make your users’ passwords +better.

+ +

Installation

+ +

Add this line to your application's Gemfile:

+ +
gem 'pwned'
+

And then execute:

@@ -119,169 +142,200 @@

Installation

$ gem install pwned
 
-

Usage

+

Usage

There are a few ways you can use this gem:

- -
    -
  1. Plain Ruby
  2. -
  3. Rails
  4. -
  5. Rails and Devise
  6. -
- -

Plain Ruby

- -

To test a password against the API, instantiate a Pwned::Password object and then ask if it is pwned?.

- -

ruby -password = Pwned::Password.new("password") -password.pwned? -#=> true -password.pwned_count -#=> 3303003 -

+
  1. +

    Plain Ruby

    +
  2. +

    Rails

    +
  3. +

    Rails and Devise

    +
+ +

Plain Ruby

+ +

To test a password against the API, instantiate a +Pwned::Password object and then ask if it is +pwned?.

+ +
password = Pwned::Password.new("password")
+password.pwned?
+#=> true
+password.pwned_count
+#=> 3303003
+

You can also check how many times the password appears in the dataset.

-

ruby -password = Pwned::Password.new("password") -password.pwned_count -#=> 3303003 -

- -

Since you are likely using this as part of a signup flow, it is recommended that you rescue errors so if the service does go down, your user journey is not disturbed.

- -

ruby -begin - password = Pwned::Password.new("password") - password.pwned? -rescue Pwned::Error => e - # Ummm... don't worry about it, I guess? -end -

+
password = Pwned::Password.new("password")
+password.pwned_count
+#=> 3303003
+
+ +

Since you are likely using this as part of a signup flow, it is recommended +that you rescue errors so if the service does go down, your user journey is +not disturbed.

+ +
begin
+  password = Pwned::Password.new("password")
+  password.pwned?
+rescue Pwned::Error => e
+  # Ummm... don't worry about it, I guess?
+end
+
-

Most of the times you only care if the password has been pwned before or not. You can use simplified accessors to check whether the password has been pwned, or how many times it was pwned:

+

Most of the times you only care if the password has been pwned before or +not. You can use simplified accessors to check whether the password has +been pwned, or how many times it was pwned:

-

ruby -Pwned.pwned?("password") -#=> true -Pwned.pwned_count("password") -#=> 3303003 -

+
Pwned.pwned?("password")
+#=> true
+Pwned.pwned_count("password")
+#=> 3303003
+
-

Advanced

+

Advanced

-

You can set http request options to be used with Net::HTTP.start when making the request to the API. These options are -documented in the Net::HTTP.start documentation. The :headers option defines defines HTTP headers. These headers must be string keys.

+

You can set http request options to be used with +Net::HTTP.start when making the request to the API. These +options are documented in the Net::HTTP.start +documentation. The :headers option defines defines HTTP +headers. These headers must be string keys.

-

ruby -password = Pwned::Password.new("password", headers: { 'User-Agent' => 'Super fun new user agent' }, read_timeout: 10) -

+
password = Pwned::Password.new("password", headers: { 'User-Agent' => 'Super fun new user agent' }, read_timeout: 10)
+
-

ActiveRecord Validator

+

ActiveRecord Validator

There is a custom validator available for your ActiveRecord models:

-

ruby -class User < ApplicationRecord - validates :password, not_pwned: true - # or - validates :password, not_pwned: { message: "has been pwned %{count} times" } -end -

+
class User < ApplicationRecord
+  validates :password, not_pwned: true
+  # or
+  validates :password, not_pwned: { message: "has been pwned %{count} times" }
+end
+
-

I18n

+

I18n

-

You can change the error message using I18n (use %{count} to interpolate the number of times the password was seen in the data breaches):

+

You can change the error message using I18n (use %{count} to +interpolate the number of times the password was seen in the data +breaches):

-

yaml -en: +

en:
   errors:
     messages:
       not_pwned: has been pwned %{count} times
       pwned_error: might be pwned
-

+
-

Threshold

+

Threshold

-

If you are ok with the password appearing a certain number of times before you decide it is invalid, you can set a threshold. The validator will check whether the pwned_count is greater than the threshold.

+

If you are ok with the password appearing a certain number of times before +you decide it is invalid, you can set a threshold. The validator will check +whether the pwned_count is greater than the threshold.

-

ruby -class User < ApplicationRecord - # The record is marked as valid if the password has been used once in the breached data - validates :password, not_pwned: { threshold: 1 } -end -

+
class User < ApplicationRecord
+  # The record is marked as valid if the password has been used once in the breached data
+  validates :password, not_pwned: { threshold: 1 }
+end
+
-

Network Error Handling

+

Network Error Handling

-

By default the record will be treated as valid when we cannot reach the haveibeenpwned.com servers. This can be changed with the :on_error validator parameter:

+

By default the record will be treated as valid when we cannot reach the haveibeenpwned.com servers. This can +be changed with the :on_error validator parameter:

-

```ruby -class User < ApplicationRecord - # The record is marked as valid on network errors. - validates :password, not_pwned: true - validates :password, not_pwned: { on_error: :valid }

+
class User < ApplicationRecord
+  # The record is marked as valid on network errors.
+  validates :password, not_pwned: true
+  validates :password, not_pwned: { on_error: :valid }
 
-

# The record is marked as invalid on network errors - # (error message “could not be verified against the past data breaches”.) - validates :password, not_pwned: { on_error: :invalid }

+ # The record is marked as invalid on network errors + # (error message "could not be verified against the past data breaches".) + validates :password, not_pwned: { on_error: :invalid } -

# The record is marked as invalid on network errors with custom error. - validates :password, not_pwned: { on_error: :invalid, error_message: “might be pwned” }

+ # The record is marked as invalid on network errors with custom error. + validates :password, not_pwned: { on_error: :invalid, error_message: "might be pwned" } -

# We will raise an error on network errors. - # This means that record.valid? will raise Pwned::Error. - # Not recommended to use in production. - validates :password, not_pwned: { on_error: :raise_error }

+ # We will raise an error on network errors. + # This means that `record.valid?` will raise `Pwned::Error`. + # Not recommended to use in production. + validates :password, not_pwned: { on_error: :raise_error } -

# Call custom proc on error. For example, capture errors in Sentry, - # but do not mark the record as invalid. - validates :password, not_pwned: { - on_error: ->(record, error) { Raven.capture_exception(error) } - } -end -```

+ # Call custom proc on error. For example, capture errors in Sentry, + # but do not mark the record as invalid. + validates :password, not_pwned: { + on_error: ->(record, error) { Raven.capture_exception(error) } + } +end +
-

Custom Request Options

+

Custom Request Options

-

You can configure network requests made from the validator using :request_options (see Net::HTTP.start for the list of available options). -In addition to these options, HTTP headers can be specified with the :headers key, e.g. "User-Agent"):

+

You can configure network requests made from the validator using +:request_options (see Net::HTTP.start +for the list of available options). In addition to these options, HTTP +headers can be specified with the :headers key, e.g. +"User-Agent"):

-

ruby - validates :password, not_pwned: { - request_options: { read_timeout: 5, open_timeout: 1, headers: { "User-Agent" => "Super fun user agent" } } - } -

+
validates :password, not_pwned: {
+    request_options: { read_timeout: 5, open_timeout: 1, headers: { "User-Agent" => "Super fun user agent" } }
+  }
+
-

Devise

+

Devise

-

If you are using Devise I recommend you use the devise-pwned_password extension which is now powered by this gem.

+

If you are using Devise I recommend you use the devise-pwned_password +extension which is now powered by this gem.

-

How Pwned is Pi?

+

Command line

-

@daz shared a fantastic example of using this gem to show how many times the digits of Pi have been used as passwords and leaked.

+

The gem provides a command line utility for checking passwords. You can +call it from your terminal application like this:

-

```ruby -require ‘pwned’

+
$ pwned password
+Pwned!
+The password has been found in public breaches 3645804 times.
+
-

PI = ‘3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111’

+

If you don't want the password you are checking to be visible, call:

-

for n in 1..40 - password = Pwned::Password.new PI[0..(n + 1)] - str = [ n.to_s.rjust(2) ] - str « (password.pwned? ? ‘😡’ : ‘😃’) - str « password.pwned_count.to_s.rjust(4) - str « password.password

+
$ pwned --secret
+
-

puts str.join ‘ ‘ -end -```

+

You will be prompted for the password, but it won't be displayed.

+ +

How Pwned is Pi?

+ +

@daz shared a +fantastic example of using this gem to show how many times the digits of Pi +have been used as passwords and leaked.

+ +
require 'pwned'
+
+PI = '3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111'
+
+for n in 1..40
+  password = Pwned::Password.new PI[0..(n + 1)]
+  str = [ n.to_s.rjust(2) ]
+  str << (password.pwned? ? '😡' : '😃')
+  str << password.pwned_count.to_s.rjust(4)
+  str << password.password
+
+  puts str.join ' '
+end
+

The results may, or may not, surprise you.

-

- 1 😡 16 3.1 +

1 😡   16 3.1
  2 😡  238 3.14
  3 😡   34 3.141
  4 😡 1345 3.1415
@@ -321,31 +375,48 @@ 

How Pwned is Pi?

38 😃 0 3.14159265358979323846264338327950288419 39 😃 0 3.141592653589793238462643383279502884197 40 😃 0 3.1415926535897932384626433832795028841971 -

+
-

Development

+

Development

-

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

+

After checking out the repo, run bin/setup to install +dependencies. Then, run rake spec to run the tests. You can +also run bin/console for an interactive prompt that will allow +you to experiment.

-

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

+

To install this gem onto your local machine, run bundle exec rake +install. To release a new version, update the version number in +version.rb, and then run bundle exec rake +release, which will create a git tag for the version, push git +commits and tags, and push the .gem file to rubygems.org.

-

Contributing

+

Contributing

-

Bug reports and pull requests are welcome on GitHub at https://github.com/philnash/pwned. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

+

Bug reports and pull requests are welcome on GitHub at github.com/philnash/pwned. +This project is intended to be a safe, welcoming space for collaboration, +and contributors are expected to adhere to the Contributor Covenant code of +conduct.

-

License

+

License

-

The gem is available as open source under the terms of the MIT License.

+

The gem is available as open source under the terms of the MIT License.

-

Code of Conduct

+

Code of Conduct

-

Everyone interacting in the Pwned project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

+

Everyone interacting in the Pwned project’s codebases, issue trackers, chat +rooms and mailing lists is expected to follow the code +of conduct.

diff --git a/docs/index.html b/docs/index.html index 15b9df3..6b2b589 100644 --- a/docs/index.html +++ b/docs/index.html @@ -57,57 +57,80 @@
-

Pwned

+
+

Pwned

An easy, Ruby way to use the Pwned Passwords API.

-

Gem Version Build Status Maintainability Inline docs

- - - - - - - - -
API docsGitHub repo
- -

Table of Contents

- - - -

About

- -

Troy Hunt’s Pwned Passwords API V2 allows you to check if a password has been found in any of the huge data breaches.

- -

Pwned is a Ruby library to use the Pwned Passwords API’s k-Anonymity model to test a password against the API without sending the entire password to the service.

- -

The data from this API is provided by Have I been pwned?. Before using the API, please check the acceptable uses and license of the API.

- -

Here is a blog post I wrote on how to use this gem in your Ruby applications to make your users’ passwords better.

- -

Installation

- -

Add this line to your application’s Gemfile:

- -

ruby -gem 'pwned' -

+

+ +

API docs | GitHub repo

+ +

Table of Contents

+ + +

About

+ +

Troy Hunt's Pwned Passwords API +V2 allows you to check if a password has been found in any of the huge +data breaches.

+ +

Pwned is a Ruby library to use the Pwned Passwords API's +k-Anonymity +model to test a password against the API without sending the entire +password to the service.

+ +

The data from this API is provided by Have I been pwned?. Before using the +API, please check the acceptable uses +and license of the API.

+ +

Here is a blog post I wrote on how +to use this gem in your Ruby applications to make your users’ passwords +better.

+ +

Installation

+ +

Add this line to your application's Gemfile:

+ +
gem 'pwned'
+

And then execute:

@@ -119,169 +142,200 @@

Installation

$ gem install pwned
 
-

Usage

+

Usage

There are a few ways you can use this gem:

- -
    -
  1. Plain Ruby
  2. -
  3. Rails
  4. -
  5. Rails and Devise
  6. -
- -

Plain Ruby

- -

To test a password against the API, instantiate a Pwned::Password object and then ask if it is pwned?.

- -

ruby -password = Pwned::Password.new("password") -password.pwned? -#=> true -password.pwned_count -#=> 3303003 -

+
  1. +

    Plain Ruby

    +
  2. +

    Rails

    +
  3. +

    Rails and Devise

    +
+ +

Plain Ruby

+ +

To test a password against the API, instantiate a +Pwned::Password object and then ask if it is +pwned?.

+ +
password = Pwned::Password.new("password")
+password.pwned?
+#=> true
+password.pwned_count
+#=> 3303003
+

You can also check how many times the password appears in the dataset.

-

ruby -password = Pwned::Password.new("password") -password.pwned_count -#=> 3303003 -

- -

Since you are likely using this as part of a signup flow, it is recommended that you rescue errors so if the service does go down, your user journey is not disturbed.

- -

ruby -begin - password = Pwned::Password.new("password") - password.pwned? -rescue Pwned::Error => e - # Ummm... don't worry about it, I guess? -end -

+
password = Pwned::Password.new("password")
+password.pwned_count
+#=> 3303003
+
+ +

Since you are likely using this as part of a signup flow, it is recommended +that you rescue errors so if the service does go down, your user journey is +not disturbed.

+ +
begin
+  password = Pwned::Password.new("password")
+  password.pwned?
+rescue Pwned::Error => e
+  # Ummm... don't worry about it, I guess?
+end
+
-

Most of the times you only care if the password has been pwned before or not. You can use simplified accessors to check whether the password has been pwned, or how many times it was pwned:

+

Most of the times you only care if the password has been pwned before or +not. You can use simplified accessors to check whether the password has +been pwned, or how many times it was pwned:

-

ruby -Pwned.pwned?("password") -#=> true -Pwned.pwned_count("password") -#=> 3303003 -

+
Pwned.pwned?("password")
+#=> true
+Pwned.pwned_count("password")
+#=> 3303003
+
-

Advanced

+

Advanced

-

You can set http request options to be used with Net::HTTP.start when making the request to the API. These options are -documented in the Net::HTTP.start documentation. The :headers option defines defines HTTP headers. These headers must be string keys.

+

You can set http request options to be used with +Net::HTTP.start when making the request to the API. These +options are documented in the Net::HTTP.start +documentation. The :headers option defines defines HTTP +headers. These headers must be string keys.

-

ruby -password = Pwned::Password.new("password", headers: { 'User-Agent' => 'Super fun new user agent' }, read_timeout: 10) -

+
password = Pwned::Password.new("password", headers: { 'User-Agent' => 'Super fun new user agent' }, read_timeout: 10)
+
-

ActiveRecord Validator

+

ActiveRecord Validator

There is a custom validator available for your ActiveRecord models:

-

ruby -class User < ApplicationRecord - validates :password, not_pwned: true - # or - validates :password, not_pwned: { message: "has been pwned %{count} times" } -end -

+
class User < ApplicationRecord
+  validates :password, not_pwned: true
+  # or
+  validates :password, not_pwned: { message: "has been pwned %{count} times" }
+end
+
-

I18n

+

I18n

-

You can change the error message using I18n (use %{count} to interpolate the number of times the password was seen in the data breaches):

+

You can change the error message using I18n (use %{count} to +interpolate the number of times the password was seen in the data +breaches):

-

yaml -en: +

en:
   errors:
     messages:
       not_pwned: has been pwned %{count} times
       pwned_error: might be pwned
-

+
-

Threshold

+

Threshold

-

If you are ok with the password appearing a certain number of times before you decide it is invalid, you can set a threshold. The validator will check whether the pwned_count is greater than the threshold.

+

If you are ok with the password appearing a certain number of times before +you decide it is invalid, you can set a threshold. The validator will check +whether the pwned_count is greater than the threshold.

-

ruby -class User < ApplicationRecord - # The record is marked as valid if the password has been used once in the breached data - validates :password, not_pwned: { threshold: 1 } -end -

+
class User < ApplicationRecord
+  # The record is marked as valid if the password has been used once in the breached data
+  validates :password, not_pwned: { threshold: 1 }
+end
+
-

Network Error Handling

+

Network Error Handling

-

By default the record will be treated as valid when we cannot reach the haveibeenpwned.com servers. This can be changed with the :on_error validator parameter:

+

By default the record will be treated as valid when we cannot reach the haveibeenpwned.com servers. This can +be changed with the :on_error validator parameter:

-

```ruby -class User < ApplicationRecord - # The record is marked as valid on network errors. - validates :password, not_pwned: true - validates :password, not_pwned: { on_error: :valid }

+
class User < ApplicationRecord
+  # The record is marked as valid on network errors.
+  validates :password, not_pwned: true
+  validates :password, not_pwned: { on_error: :valid }
 
-

# The record is marked as invalid on network errors - # (error message “could not be verified against the past data breaches”.) - validates :password, not_pwned: { on_error: :invalid }

+ # The record is marked as invalid on network errors + # (error message "could not be verified against the past data breaches".) + validates :password, not_pwned: { on_error: :invalid } -

# The record is marked as invalid on network errors with custom error. - validates :password, not_pwned: { on_error: :invalid, error_message: “might be pwned” }

+ # The record is marked as invalid on network errors with custom error. + validates :password, not_pwned: { on_error: :invalid, error_message: "might be pwned" } -

# We will raise an error on network errors. - # This means that record.valid? will raise Pwned::Error. - # Not recommended to use in production. - validates :password, not_pwned: { on_error: :raise_error }

+ # We will raise an error on network errors. + # This means that `record.valid?` will raise `Pwned::Error`. + # Not recommended to use in production. + validates :password, not_pwned: { on_error: :raise_error } -

# Call custom proc on error. For example, capture errors in Sentry, - # but do not mark the record as invalid. - validates :password, not_pwned: { - on_error: ->(record, error) { Raven.capture_exception(error) } - } -end -```

+ # Call custom proc on error. For example, capture errors in Sentry, + # but do not mark the record as invalid. + validates :password, not_pwned: { + on_error: ->(record, error) { Raven.capture_exception(error) } + } +end +
-

Custom Request Options

+

Custom Request Options

-

You can configure network requests made from the validator using :request_options (see Net::HTTP.start for the list of available options). -In addition to these options, HTTP headers can be specified with the :headers key, e.g. "User-Agent"):

+

You can configure network requests made from the validator using +:request_options (see Net::HTTP.start +for the list of available options). In addition to these options, HTTP +headers can be specified with the :headers key, e.g. +"User-Agent"):

-

ruby - validates :password, not_pwned: { - request_options: { read_timeout: 5, open_timeout: 1, headers: { "User-Agent" => "Super fun user agent" } } - } -

+
validates :password, not_pwned: {
+    request_options: { read_timeout: 5, open_timeout: 1, headers: { "User-Agent" => "Super fun user agent" } }
+  }
+
-

Devise

+

Devise

-

If you are using Devise I recommend you use the devise-pwned_password extension which is now powered by this gem.

+

If you are using Devise I recommend you use the devise-pwned_password +extension which is now powered by this gem.

-

How Pwned is Pi?

+

Command line

-

@daz shared a fantastic example of using this gem to show how many times the digits of Pi have been used as passwords and leaked.

+

The gem provides a command line utility for checking passwords. You can +call it from your terminal application like this:

-

```ruby -require ‘pwned’

+
$ pwned password
+Pwned!
+The password has been found in public breaches 3645804 times.
+
-

PI = ‘3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111’

+

If you don't want the password you are checking to be visible, call:

-

for n in 1..40 - password = Pwned::Password.new PI[0..(n + 1)] - str = [ n.to_s.rjust(2) ] - str « (password.pwned? ? ‘😡’ : ‘😃’) - str « password.pwned_count.to_s.rjust(4) - str « password.password

+
$ pwned --secret
+
-

puts str.join ‘ ‘ -end -```

+

You will be prompted for the password, but it won't be displayed.

+ +

How Pwned is Pi?

+ +

@daz shared a +fantastic example of using this gem to show how many times the digits of Pi +have been used as passwords and leaked.

+ +
require 'pwned'
+
+PI = '3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111'
+
+for n in 1..40
+  password = Pwned::Password.new PI[0..(n + 1)]
+  str = [ n.to_s.rjust(2) ]
+  str << (password.pwned? ? '😡' : '😃')
+  str << password.pwned_count.to_s.rjust(4)
+  str << password.password
+
+  puts str.join ' '
+end
+

The results may, or may not, surprise you.

-

- 1 😡 16 3.1 +

1 😡   16 3.1
  2 😡  238 3.14
  3 😡   34 3.141
  4 😡 1345 3.1415
@@ -321,31 +375,48 @@ 

How Pwned is Pi?

38 😃 0 3.14159265358979323846264338327950288419 39 😃 0 3.141592653589793238462643383279502884197 40 😃 0 3.1415926535897932384626433832795028841971 -

+
-

Development

+

Development

-

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

+

After checking out the repo, run bin/setup to install +dependencies. Then, run rake spec to run the tests. You can +also run bin/console for an interactive prompt that will allow +you to experiment.

-

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

+

To install this gem onto your local machine, run bundle exec rake +install. To release a new version, update the version number in +version.rb, and then run bundle exec rake +release, which will create a git tag for the version, push git +commits and tags, and push the .gem file to rubygems.org.

-

Contributing

+

Contributing

-

Bug reports and pull requests are welcome on GitHub at https://github.com/philnash/pwned. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

+

Bug reports and pull requests are welcome on GitHub at github.com/philnash/pwned. +This project is intended to be a safe, welcoming space for collaboration, +and contributors are expected to adhere to the Contributor Covenant code of +conduct.

-

License

+

License

-

The gem is available as open source under the terms of the MIT License.

+

The gem is available as open source under the terms of the MIT License.

-

Code of Conduct

+

Code of Conduct

-

Everyone interacting in the Pwned project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

+

Everyone interacting in the Pwned project’s codebases, issue trackers, chat +rooms and mailing lists is expected to follow the code +of conduct.

diff --git a/docs/top-level-namespace.html b/docs/top-level-namespace.html index 6484d9c..087023b 100644 --- a/docs/top-level-namespace.html +++ b/docs/top-level-namespace.html @@ -102,9 +102,9 @@

Defined Under Namespace