Module: Pwned

Defined in:
lib/pwned.rb,
lib/pwned/error.rb,
lib/pwned/version.rb,
lib/pwned/password.rb

Overview

The main namespace for Pwned. Includes convenience methods for getting the results for a password.

Defined Under Namespace

Classes: Error, Password, TimeoutError

Constant Summary collapse

VERSION =

The current version of the pwned gem.

"1.2.1"

Class Method Summary collapse

Class Method Details

.pwned?(password, request_options = {}) ⇒ Boolean

Returns true when the password has been pwned.

Examples:

Pwned.pwned?("password") #=> true
Pwned.pwned?("pwned::password") #=> false

Options Hash (request_options):

  • 'User-Agent' (String) — default: "Ruby Pwned::Password #{Pwned::VERSION}"

    The user agent used when making an API request.

Since:

  • 1.1.0


38
39
40
# File 'lib/pwned.rb', line 38

def self.pwned?(password, request_options={})
  Pwned::Password.new(password, request_options).pwned?
end

.pwned_count(password, request_options = {}) ⇒ Integer

Returns number of times the password has been pwned.

Examples:

Pwned.pwned_count("password") #=> 3303003
Pwned.pwned_count("pwned::password") #=> 0

Options Hash (request_options):

  • 'User-Agent' (String) — default: "Ruby Pwned::Password #{Pwned::VERSION}"

    The user agent used when making an API request.

Since:

  • 1.1.0


57
58
59
# File 'lib/pwned.rb', line 57

def self.pwned_count(password, request_options={})
  Pwned::Password.new(password, request_options).pwned_count
end