Class: Pwned::HashedPassword
- Inherits:
-
Object
- Object
- Pwned::HashedPassword
- Includes:
- PasswordBase
- Defined in:
- lib/pwned/hashed_password.rb
Overview
This class represents a hashed 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
PasswordBase::API_URL, PasswordBase::DEFAULT_REQUEST_HEADERS, PasswordBase::HASH_PREFIX_LENGTH, PasswordBase::SHA1_LENGTH
Instance Attribute Summary
Attributes included from PasswordBase
Instance Method Summary collapse
-
#initialize(hashed_password, request_options = {}) ⇒ HashedPassword
constructor
Creates a new hashed password object.
Methods included from PasswordBase
Constructor Details
#initialize(hashed_password, request_options = {}) ⇒ HashedPassword
Creates a new hashed password object.
33 34 35 36 37 38 39 40 41 |
# File 'lib/pwned/hashed_password.rb', line 33 def initialize(hashed_password, ={}) raise TypeError, "hashed_password must be of type String" unless hashed_password.is_a? String @hashed_password = hashed_password.upcase @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 |