Class: Pwned::Password
- Inherits:
-
Object
- Object
- Pwned::Password
- Includes:
- PasswordBase
- Defined in:
- lib/pwned/password.rb
Overview
This class represents a password. It does all the work of talking to the Pwned Passwords API to find out if the password has been pwned.
Constant Summary
Constants included from PasswordBase
Pwned::PasswordBase::API_URL, Pwned::PasswordBase::DEFAULT_REQUEST_HEADERS, Pwned::PasswordBase::HASH_PREFIX_LENGTH, Pwned::PasswordBase::SHA1_LENGTH
Instance Attribute Summary collapse
-
#password ⇒ String
readonly
The password that is being checked.
Attributes included from PasswordBase
Instance Method Summary collapse
-
#initialize(password, request_options = {}) ⇒ Password
constructor
Creates a new password object.
Methods included from PasswordBase
Constructor Details
#initialize(password, request_options = {}) ⇒ Password
Creates a new password object.
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/pwned/password.rb', line 37 def initialize(password, ={}) raise TypeError, "password must be of type String" unless password.is_a? String @password = password @hashed_password = Pwned.hash_password(password) @request_options = Pwned..deep_merge() @request_headers = Hash(@request_options.delete(:headers)) @request_headers = DEFAULT_REQUEST_HEADERS.merge(@request_headers) @request_proxy = URI(@request_options.delete(:proxy)) if @request_options.key?(:proxy) @ignore_env_proxy = @request_options.delete(:ignore_env_proxy) || false end |
Instance Attribute Details
#password ⇒ String (readonly)
Returns the password that is being checked.
17 18 19 |
# File 'lib/pwned/password.rb', line 17 def password @password end |