Module: Pwned
- Defined in:
- lib/pwned.rb,
lib/pwned/error.rb,
lib/pwned/version.rb,
lib/pwned/password.rb,
lib/pwned/password_base.rb,
lib/pwned/hashed_password.rb
Overview
The main namespace for Pwned
. Includes convenience methods for getting the results for a password.
Defined Under Namespace
Modules: PasswordBase Classes: Error, HashedPassword, Password, TimeoutError
Constant Summary collapse
- VERSION =
The current version of the
pwned
gem. '2.4.1'
Class Method Summary collapse
-
.default_request_options ⇒ Hash
The default request options passed to
Net::HTTP.start
when calling the API. -
.default_request_options=(request_options) ⇒ Object
Sets the default request options passed to
Net::HTTP.start
when calling the API. -
.hash_password(password) ⇒ String
Returns the full SHA1 hash of the given password in uppercase.
-
.pwned?(password, request_options = {}) ⇒ Boolean
Returns
true
when the password has been pwned. -
.pwned_count(password, request_options = {}) ⇒ Integer
Returns number of times the password has been pwned.
Class Method Details
.default_request_options ⇒ Hash
The default request options passed to Net::HTTP.start
when calling the API.
33 34 35 |
# File 'lib/pwned.rb', line 33 def self. @default_request_options end |
.default_request_options=(request_options) ⇒ Object
Sets the default request options passed to Net::HTTP.start
when calling the API.
The default options may be overridden in Pwned::Password#new.
45 46 47 |
# File 'lib/pwned.rb', line 45 def self.() @default_request_options = end |
.hash_password(password) ⇒ String
Returns the full SHA1 hash of the given password in uppercase. This can be safely passed around your code before making the pwned request (e.g. dropped into a queue table).
102 103 104 |
# File 'lib/pwned.rb', line 102 def self.hash_password(password) Digest::SHA1.hexdigest(password).upcase end |
.pwned?(password, request_options = {}) ⇒ Boolean
Returns true
when the password has been pwned.
66 67 68 |
# File 'lib/pwned.rb', line 66 def self.pwned?(password, ={}) Pwned::Password.new(password, ).pwned? end |
.pwned_count(password, request_options = {}) ⇒ Integer
Returns number of times the password has been pwned.
88 89 90 |
# File 'lib/pwned.rb', line 88 def self.pwned_count(password, ={}) Pwned::Password.new(password, ).pwned_count end |