pwned 2.0.2 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,17 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8">
5
- <title>Documentation by YARD 0.9.20</title>
6
- </head>
7
- <script type="text/javascript" charset="utf-8">
8
- var match = unescape(window.location.hash).match(/^#!(.+)/);
9
- var name = match ? match[1] : 'index.html';
10
- name = name.replace(/^(\w+):\/\//, '').replace(/^\/\//, '');
11
- window.top.location = name;
12
- </script>
13
- <noscript>
14
- <h1>Oops!</h1>
15
- <h2>YARD requires JavaScript!</h2>
16
- </noscript>
17
- </html>
@@ -1,424 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>
7
- File: README
8
-
9
- &mdash; Documentation by YARD 0.9.20
10
-
11
- </title>
12
-
13
- <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
14
-
15
- <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
16
-
17
- <script type="text/javascript" charset="utf-8">
18
- pathId = "README";
19
- relpath = '';
20
- </script>
21
-
22
-
23
- <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
24
-
25
- <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
26
-
27
-
28
- </head>
29
- <body>
30
- <div class="nav_wrap">
31
- <iframe id="nav" src="class_list.html?1"></iframe>
32
- <div id="resizer"></div>
33
- </div>
34
-
35
- <div id="main" tabindex="-1">
36
- <div id="header">
37
- <div id="menu">
38
-
39
- <a href="_index.html">Index</a> &raquo;
40
- <span class="title">File: README</span>
41
-
42
- </div>
43
-
44
- <div id="search">
45
-
46
- <a class="full_list_link" id="class_list_link"
47
- href="class_list.html">
48
-
49
- <svg width="24" height="24">
50
- <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
51
- <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
52
- <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
53
- </svg>
54
- </a>
55
-
56
- </div>
57
- <div class="clear"></div>
58
- </div>
59
-
60
- <div id="content"><div id='filecontents'>
61
- <h1 id="label-Pwned">Pwned</h1>
62
-
63
- <p>An easy, Ruby way to use the Pwned Passwords API.</p>
64
-
65
- <p><a href="https://rubygems.org/gems/pwned"><img
66
- src="https://badge.fury.io/rb/pwned.svg"></a> <a
67
- href="https://travis-ci.org/philnash/pwned"><img
68
- src="https://travis-ci.org/philnash/pwned.svg?branch=master"></a> <a
69
- href="https://codeclimate.com/github/philnash/pwned/maintainability"><img
70
- src="https://codeclimate.com/github/philnash/pwned/badges/gpa.svg"></a> <a
71
- href="https://inch-ci.org/github/philnash/pwned"><img
72
- src="https://inch-ci.org/github/philnash/pwned.svg?branch=master"></a></p>
73
-
74
- <p><a href="https://philnash.github.io/pwned/">API docs</a> | <a
75
- href="https://github.com/philnash/pwned">GitHub repo</a></p>
76
-
77
- <h2 id="label-Table+of+Contents">Table of Contents</h2>
78
- <ul><li>
79
- <p><a href="#about">About</a></p>
80
- </li><li>
81
- <p><a href="#installation">Installation</a></p>
82
- </li><li>
83
- <p><a href="#usage">Usage</a></p>
84
- </li><li>
85
- <p><a href="#plain-ruby">Plain Ruby</a></p>
86
- </li><li>
87
- <p><a href="#activerecord-validator">Rails (ActiveRecord)</a></p>
88
- </li><li>
89
- <p><a href="#devise">Devise</a></p>
90
- </li><li>
91
- <p><a href="#command-line">Command line</a></p>
92
- </li><li>
93
- <p><a href="#how-pwned-is-pi">How Pwned is Pi?</a></p>
94
- </li><li>
95
- <p><a href="#development">Development</a></p>
96
- </li><li>
97
- <p><a href="#contributing">Contributing</a></p>
98
- </li><li>
99
- <p><a href="#license">License</a></p>
100
- </li><li>
101
- <p><a href="#code-of-conduct">Code of Conduct</a></p>
102
- </li></ul>
103
-
104
- <h2 id="label-About">About</h2>
105
-
106
- <p>Troy Hunt&#39;s <a
107
- href="https://haveibeenpwned.com/API/v2#PwnedPasswords">Pwned Passwords API
108
- V2</a> allows you to check if a password has been found in any of the huge
109
- data breaches.</p>
110
-
111
- <p><code>Pwned</code> is a Ruby library to use the Pwned Passwords API&#39;s
112
- <a
113
- href="https://www.troyhunt.com/ive-just-launched-pwned-passwords-version-2/#cloudflareprivacyandkanonymity">k-Anonymity
114
- model</a> to test a password against the API without sending the entire
115
- password to the service.</p>
116
-
117
- <p>The data from this API is provided by <a
118
- href="https://haveibeenpwned.com/">Have I been pwned?</a>. Before using the
119
- API, please check <a
120
- href="https://haveibeenpwned.com/API/v2#AcceptableUse">the acceptable uses
121
- and license of the API</a>.</p>
122
-
123
- <p>Here is a blog post I wrote on <a
124
- href="https://www.twilio.com/blog/2018/03/better-passwords-in-ruby-applications-pwned-passwords-api.html">how
125
- to use this gem in your Ruby applications to make your users’ passwords
126
- better</a>.</p>
127
-
128
- <h2 id="label-Installation">Installation</h2>
129
-
130
- <p>Add this line to your application&#39;s Gemfile:</p>
131
-
132
- <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_gem'>gem</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>pwned</span><span class='tstring_end'>&#39;</span></span>
133
- </code></pre>
134
-
135
- <p>And then execute:</p>
136
-
137
- <pre class="code ruby"><code class="ruby">$ bundle
138
- </code></pre>
139
-
140
- <p>Or install it yourself as:</p>
141
-
142
- <pre class="code ruby"><code class="ruby">$ gem install pwned
143
- </code></pre>
144
-
145
- <h2 id="label-Usage">Usage</h2>
146
-
147
- <p>There are a few ways you can use this gem:</p>
148
- <ol><li>
149
- <p><a href="#plain-ruby">Plain Ruby</a></p>
150
- </li><li>
151
- <p><a href="#activerecord-validator">Rails</a></p>
152
- </li><li>
153
- <p><a href="#devise">Rails and Devise</a></p>
154
- </li></ol>
155
-
156
- <h3 id="label-Plain+Ruby">Plain Ruby</h3>
157
-
158
- <p>To test a password against the API, instantiate a
159
- <code>Pwned::Password</code> object and then ask if it is
160
- <code>pwned?</code>.</p>
161
-
162
- <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_password'>password</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Pwned.html" title="Pwned (module)">Pwned</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Pwned/Password.html" title="Pwned::Password (class)">Password</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Pwned/Password.html#initialize-instance_method" title="Pwned::Password#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>password</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
163
- <span class='id identifier rubyid_password'>password</span><span class='period'>.</span><span class='id identifier rubyid_pwned?'>pwned?</span>
164
- <span class='comment'>#=&gt; true
165
- </span><span class='id identifier rubyid_password'>password</span><span class='period'>.</span><span class='id identifier rubyid_pwned_count'>pwned_count</span>
166
- <span class='comment'>#=&gt; 3303003
167
- </span></code></pre>
168
-
169
- <p>You can also check how many times the password appears in the dataset.</p>
170
-
171
- <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_password'>password</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Pwned.html" title="Pwned (module)">Pwned</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Pwned/Password.html" title="Pwned::Password (class)">Password</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Pwned/Password.html#initialize-instance_method" title="Pwned::Password#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>password</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
172
- <span class='id identifier rubyid_password'>password</span><span class='period'>.</span><span class='id identifier rubyid_pwned_count'>pwned_count</span>
173
- <span class='comment'>#=&gt; 3303003
174
- </span></code></pre>
175
-
176
- <p>Since you are likely using this as part of a signup flow, it is recommended
177
- that you rescue errors so if the service does go down, your user journey is
178
- not disturbed.</p>
179
-
180
- <pre class="code ruby"><code class="ruby"><span class='kw'>begin</span>
181
- <span class='id identifier rubyid_password'>password</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Pwned.html" title="Pwned (module)">Pwned</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Pwned/Password.html" title="Pwned::Password (class)">Password</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Pwned/Password.html#initialize-instance_method" title="Pwned::Password#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>password</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
182
- <span class='id identifier rubyid_password'>password</span><span class='period'>.</span><span class='id identifier rubyid_pwned?'>pwned?</span>
183
- <span class='kw'>rescue</span> <span class='const'><span class='object_link'><a href="Pwned.html" title="Pwned (module)">Pwned</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Pwned/Error.html" title="Pwned::Error (class)">Error</a></span></span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
184
- <span class='comment'># Ummm... don&#39;t worry about it, I guess?
185
- </span><span class='kw'>end</span>
186
- </code></pre>
187
-
188
- <p>Most of the times you only care if the password has been pwned before or
189
- not. You can use simplified accessors to check whether the password has
190
- been pwned, or how many times it was pwned:</p>
191
-
192
- <pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="Pwned.html" title="Pwned (module)">Pwned</a></span></span><span class='period'>.</span><span class='id identifier rubyid_pwned?'><span class='object_link'><a href="Pwned.html#pwned%3F-class_method" title="Pwned.pwned? (method)">pwned?</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>password</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
193
- <span class='comment'>#=&gt; true
194
- </span><span class='const'><span class='object_link'><a href="Pwned.html" title="Pwned (module)">Pwned</a></span></span><span class='period'>.</span><span class='id identifier rubyid_pwned_count'><span class='object_link'><a href="Pwned.html#pwned_count-class_method" title="Pwned.pwned_count (method)">pwned_count</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>password</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
195
- <span class='comment'>#=&gt; 3303003
196
- </span></code></pre>
197
-
198
- <h4 id="label-Advanced">Advanced</h4>
199
-
200
- <p>You can set http request options to be used with
201
- <code>Net::HTTP.start</code> when making the request to the API. These
202
- options are documented in the <a
203
- href="http://ruby-doc.org/stdlib-2.6.3/libdoc/net/http/rdoc/Net/HTTP.html#method-c-start">Net::HTTP.start
204
- documentation</a>. The <code>:headers</code> option defines defines HTTP
205
- headers. These headers must be string keys.</p>
206
-
207
- <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_password'>password</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Pwned.html" title="Pwned (module)">Pwned</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Pwned/Password.html" title="Pwned::Password (class)">Password</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Pwned/Password.html#initialize-instance_method" title="Pwned::Password#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>password</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='label'>headers:</span> <span class='lbrace'>{</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>User-Agent</span><span class='tstring_end'>&#39;</span></span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Super fun new user agent</span><span class='tstring_end'>&#39;</span></span> <span class='rbrace'>}</span><span class='comma'>,</span> <span class='label'>read_timeout:</span> <span class='int'>10</span><span class='rparen'>)</span>
208
- </code></pre>
209
-
210
- <h3 id="label-ActiveRecord+Validator">ActiveRecord Validator</h3>
211
-
212
- <p>There is a custom validator available for your ActiveRecord models:</p>
213
-
214
- <pre class="code ruby"><code class="ruby"><span class='kw'>class</span> <span class='const'>User</span> <span class='op'>&lt;</span> <span class='const'>ApplicationRecord</span>
215
- <span class='id identifier rubyid_validates'>validates</span> <span class='symbol'>:password</span><span class='comma'>,</span> <span class='label'>not_pwned:</span> <span class='kw'>true</span>
216
- <span class='comment'># or
217
- </span> <span class='id identifier rubyid_validates'>validates</span> <span class='symbol'>:password</span><span class='comma'>,</span> <span class='label'>not_pwned:</span> <span class='lbrace'>{</span> <span class='label'>message:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>has been pwned %{count} times</span><span class='tstring_end'>&quot;</span></span> <span class='rbrace'>}</span>
218
- <span class='kw'>end</span>
219
- </code></pre>
220
-
221
- <h4 id="label-I18n">I18n</h4>
222
-
223
- <p>You can change the error message using I18n (use <code>%{count}</code> to
224
- interpolate the number of times the password was seen in the data
225
- breaches):</p>
226
-
227
- <pre class="code ruby"><code class="ruby">en:
228
- errors:
229
- messages:
230
- not_pwned: has been pwned %{count} times
231
- pwned_error: might be pwned
232
- </code></pre>
233
-
234
- <h4 id="label-Threshold">Threshold</h4>
235
-
236
- <p>If you are ok with the password appearing a certain number of times before
237
- you decide it is invalid, you can set a threshold. The validator will check
238
- whether the <code>pwned_count</code> is greater than the threshold.</p>
239
-
240
- <pre class="code ruby"><code class="ruby"><span class='kw'>class</span> <span class='const'>User</span> <span class='op'>&lt;</span> <span class='const'>ApplicationRecord</span>
241
- <span class='comment'># The record is marked as valid if the password has been used once in the breached data
242
- </span> <span class='id identifier rubyid_validates'>validates</span> <span class='symbol'>:password</span><span class='comma'>,</span> <span class='label'>not_pwned:</span> <span class='lbrace'>{</span> <span class='label'>threshold:</span> <span class='int'>1</span> <span class='rbrace'>}</span>
243
- <span class='kw'>end</span>
244
- </code></pre>
245
-
246
- <h4 id="label-Network+Error+Handling">Network Error Handling</h4>
247
-
248
- <p>By default the record will be treated as valid when we cannot reach the <a
249
- href="https://haveibeenpwned.com/">haveibeenpwned.com</a> servers. This can
250
- be changed with the <code>:on_error</code> validator parameter:</p>
251
-
252
- <pre class="code ruby"><code class="ruby"><span class='kw'>class</span> <span class='const'>User</span> <span class='op'>&lt;</span> <span class='const'>ApplicationRecord</span>
253
- <span class='comment'># The record is marked as valid on network errors.
254
- </span> <span class='id identifier rubyid_validates'>validates</span> <span class='symbol'>:password</span><span class='comma'>,</span> <span class='label'>not_pwned:</span> <span class='kw'>true</span>
255
- <span class='id identifier rubyid_validates'>validates</span> <span class='symbol'>:password</span><span class='comma'>,</span> <span class='label'>not_pwned:</span> <span class='lbrace'>{</span> <span class='label'>on_error:</span> <span class='symbol'>:valid</span> <span class='rbrace'>}</span>
256
-
257
- <span class='comment'># The record is marked as invalid on network errors
258
- </span> <span class='comment'># (error message &quot;could not be verified against the past data breaches&quot;.)
259
- </span> <span class='id identifier rubyid_validates'>validates</span> <span class='symbol'>:password</span><span class='comma'>,</span> <span class='label'>not_pwned:</span> <span class='lbrace'>{</span> <span class='label'>on_error:</span> <span class='symbol'>:invalid</span> <span class='rbrace'>}</span>
260
-
261
- <span class='comment'># The record is marked as invalid on network errors with custom error.
262
- </span> <span class='id identifier rubyid_validates'>validates</span> <span class='symbol'>:password</span><span class='comma'>,</span> <span class='label'>not_pwned:</span> <span class='lbrace'>{</span> <span class='label'>on_error:</span> <span class='symbol'>:invalid</span><span class='comma'>,</span> <span class='label'>error_message:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>might be pwned</span><span class='tstring_end'>&quot;</span></span> <span class='rbrace'>}</span>
263
-
264
- <span class='comment'># We will raise an error on network errors.
265
- </span> <span class='comment'># This means that `record.valid?` will raise `Pwned::Error`.
266
- </span> <span class='comment'># Not recommended to use in production.
267
- </span> <span class='id identifier rubyid_validates'>validates</span> <span class='symbol'>:password</span><span class='comma'>,</span> <span class='label'>not_pwned:</span> <span class='lbrace'>{</span> <span class='label'>on_error:</span> <span class='symbol'>:raise_error</span> <span class='rbrace'>}</span>
268
-
269
- <span class='comment'># Call custom proc on error. For example, capture errors in Sentry,
270
- </span> <span class='comment'># but do not mark the record as invalid.
271
- </span> <span class='id identifier rubyid_validates'>validates</span> <span class='symbol'>:password</span><span class='comma'>,</span> <span class='label'>not_pwned:</span> <span class='lbrace'>{</span>
272
- <span class='label'>on_error:</span> <span class='tlambda'>-&gt;</span><span class='lparen'>(</span><span class='id identifier rubyid_record'>record</span><span class='comma'>,</span> <span class='id identifier rubyid_error'>error</span><span class='rparen'>)</span> <span class='tlambeg'>{</span> <span class='const'>Raven</span><span class='period'>.</span><span class='id identifier rubyid_capture_exception'>capture_exception</span><span class='lparen'>(</span><span class='id identifier rubyid_error'>error</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
273
- <span class='rbrace'>}</span>
274
- <span class='kw'>end</span>
275
- </code></pre>
276
-
277
- <h4 id="label-Custom+Request+Options">Custom Request Options</h4>
278
-
279
- <p>You can configure network requests made from the validator using
280
- <code>:request_options</code> (see <a
281
- href="http://ruby-doc.org/stdlib-2.6.3/libdoc/net/http/rdoc/Net/HTTP.html#method-c-start">Net::HTTP.start</a>
282
- for the list of available options). In addition to these options, HTTP
283
- headers can be specified with the <code>:headers</code> key, e.g.
284
- <code>&quot;User-Agent&quot;</code>):</p>
285
-
286
- <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_validates'>validates</span> <span class='symbol'>:password</span><span class='comma'>,</span> <span class='label'>not_pwned:</span> <span class='lbrace'>{</span>
287
- <span class='label'>request_options:</span> <span class='lbrace'>{</span> <span class='label'>read_timeout:</span> <span class='int'>5</span><span class='comma'>,</span> <span class='label'>open_timeout:</span> <span class='int'>1</span><span class='comma'>,</span> <span class='label'>headers:</span> <span class='lbrace'>{</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>User-Agent</span><span class='tstring_end'>&quot;</span></span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Super fun user agent</span><span class='tstring_end'>&quot;</span></span> <span class='rbrace'>}</span> <span class='rbrace'>}</span>
288
- <span class='rbrace'>}</span>
289
- </code></pre>
290
-
291
- <h3 id="label-Devise">Devise</h3>
292
-
293
- <p>If you are using Devise I recommend you use the <a
294
- href="https://github.com/michaelbanfield/devise-pwned_password">devise-pwned_password
295
- extension</a> which is now powered by this gem.</p>
296
-
297
- <h3 id="label-Command+line">Command line</h3>
298
-
299
- <p>The gem provides a command line utility for checking passwords. You can
300
- call it from your terminal application like this:</p>
301
-
302
- <pre class="code ruby"><code class="ruby">$ pwned password
303
- Pwned!
304
- The password has been found in public breaches 3645804 times.
305
- </code></pre>
306
-
307
- <p>If you don&#39;t want the password you are checking to be visible, call:</p>
308
-
309
- <pre class="code ruby"><code class="ruby">$ pwned --secret
310
- </code></pre>
311
-
312
- <p>You will be prompted for the password, but it won&#39;t be displayed.</p>
313
-
314
- <h2 id="label-How+Pwned+is+Pi-3F">How Pwned is Pi?</h2>
315
-
316
- <p><a href="https://github.com/daz">@daz</a> <a
317
- href="https://twitter.com/dazonic/status/1074647842046660609">shared</a> a
318
- fantastic example of using this gem to show how many times the digits of Pi
319
- have been used as passwords and leaked.</p>
320
-
321
- <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>pwned</span><span class='tstring_end'>&#39;</span></span>
322
-
323
- <span class='const'>PI</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111</span><span class='tstring_end'>&#39;</span></span>
324
-
325
- <span class='kw'>for</span> <span class='id identifier rubyid_n'>n</span> <span class='kw'>in</span> <span class='int'>1</span><span class='op'>..</span><span class='int'>40</span>
326
- <span class='id identifier rubyid_password'>password</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Pwned.html" title="Pwned (module)">Pwned</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Pwned/Password.html" title="Pwned::Password (class)">Password</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Pwned/Password.html#initialize-instance_method" title="Pwned::Password#initialize (method)">new</a></span></span> <span class='const'>PI</span><span class='lbracket'>[</span><span class='int'>0</span><span class='op'>..</span><span class='lparen'>(</span><span class='id identifier rubyid_n'>n</span> <span class='op'>+</span> <span class='int'>1</span><span class='rparen'>)</span><span class='rbracket'>]</span>
327
- <span class='id identifier rubyid_str'>str</span> <span class='op'>=</span> <span class='lbracket'>[</span> <span class='id identifier rubyid_n'>n</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_rjust'>rjust</span><span class='lparen'>(</span><span class='int'>2</span><span class='rparen'>)</span> <span class='rbracket'>]</span>
328
- <span class='id identifier rubyid_str'>str</span> <span class='op'>&lt;&lt;</span> <span class='lparen'>(</span><span class='id identifier rubyid_password'>password</span><span class='period'>.</span><span class='id identifier rubyid_pwned?'>pwned?</span> <span class='op'>?</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>😡</span><span class='tstring_end'>&#39;</span></span> <span class='op'>:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>😃</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
329
- <span class='id identifier rubyid_str'>str</span> <span class='op'>&lt;&lt;</span> <span class='id identifier rubyid_password'>password</span><span class='period'>.</span><span class='id identifier rubyid_pwned_count'>pwned_count</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_rjust'>rjust</span><span class='lparen'>(</span><span class='int'>4</span><span class='rparen'>)</span>
330
- <span class='id identifier rubyid_str'>str</span> <span class='op'>&lt;&lt;</span> <span class='id identifier rubyid_password'>password</span><span class='period'>.</span><span class='id identifier rubyid_password'>password</span>
331
-
332
- <span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_str'>str</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'> </span><span class='tstring_end'>&#39;</span></span>
333
- <span class='kw'>end</span>
334
- </code></pre>
335
-
336
- <p>The results may, or may not, surprise you.</p>
337
-
338
- <pre class="code ruby"><code class="ruby">1 😡 16 3.1
339
- 2 😡 238 3.14
340
- 3 😡 34 3.141
341
- 4 😡 1345 3.1415
342
- 5 😡 2552 3.14159
343
- 6 😡 791 3.141592
344
- 7 😡 9582 3.1415926
345
- 8 😡 1591 3.14159265
346
- 9 😡 637 3.141592653
347
- 10 😡 873 3.1415926535
348
- 11 😡 137 3.14159265358
349
- 12 😡 103 3.141592653589
350
- 13 😡 65 3.1415926535897
351
- 14 😡 201 3.14159265358979
352
- 15 😡 41 3.141592653589793
353
- 16 😡 57 3.1415926535897932
354
- 17 😡 28 3.14159265358979323
355
- 18 😡 29 3.141592653589793238
356
- 19 😡 1 3.1415926535897932384
357
- 20 😡 7 3.14159265358979323846
358
- 21 😡 5 3.141592653589793238462
359
- 22 😡 2 3.1415926535897932384626
360
- 23 😡 2 3.14159265358979323846264
361
- 24 😃 0 3.141592653589793238462643
362
- 25 😡 3 3.1415926535897932384626433
363
- 26 😃 0 3.14159265358979323846264338
364
- 27 😃 0 3.141592653589793238462643383
365
- 28 😃 0 3.1415926535897932384626433832
366
- 29 😃 0 3.14159265358979323846264338327
367
- 30 😃 0 3.141592653589793238462643383279
368
- 31 😃 0 3.1415926535897932384626433832795
369
- 32 😃 0 3.14159265358979323846264338327950
370
- 33 😃 0 3.141592653589793238462643383279502
371
- 34 😃 0 3.1415926535897932384626433832795028
372
- 35 😃 0 3.14159265358979323846264338327950288
373
- 36 😃 0 3.141592653589793238462643383279502884
374
- 37 😃 0 3.1415926535897932384626433832795028841
375
- 38 😃 0 3.14159265358979323846264338327950288419
376
- 39 😃 0 3.141592653589793238462643383279502884197
377
- 40 😃 0 3.1415926535897932384626433832795028841971
378
- </code></pre>
379
-
380
- <h2 id="label-Development">Development</h2>
381
-
382
- <p>After checking out the repo, run <code>bin/setup</code> to install
383
- dependencies. Then, run <code>rake spec</code> to run the tests. You can
384
- also run <code>bin/console</code> for an interactive prompt that will allow
385
- you to experiment.</p>
386
-
387
- <p>To install this gem onto your local machine, run <code>bundle exec rake
388
- install</code>. To release a new version, update the version number in
389
- <code>version.rb</code>, and then run <code>bundle exec rake
390
- release</code>, which will create a git tag for the version, push git
391
- commits and tags, and push the <code>.gem</code> file to <a
392
- href="https://rubygems.org">rubygems.org</a>.</p>
393
-
394
- <h2 id="label-Contributing">Contributing</h2>
395
-
396
- <p>Bug reports and pull requests are welcome on GitHub at <a
397
- href="https://github.com/philnash/pwned">github.com/philnash/pwned</a>.
398
- This project is intended to be a safe, welcoming space for collaboration,
399
- and contributors are expected to adhere to the <a
400
- href="http://contributor-covenant.org">Contributor Covenant</a> code of
401
- conduct.</p>
402
-
403
- <h2 id="label-License">License</h2>
404
-
405
- <p>The gem is available as open source under the terms of the <a
406
- href="https://opensource.org/licenses/MIT">MIT License</a>.</p>
407
-
408
- <h2 id="label-Code+of+Conduct">Code of Conduct</h2>
409
-
410
- <p>Everyone interacting in the Pwned project’s codebases, issue trackers, chat
411
- rooms and mailing lists is expected to follow the <a
412
- href="https://github.com/philnash/pwned/blob/master/CODE_OF_CONDUCT.md">code
413
- of conduct</a>.</p>
414
- </div></div>
415
-
416
- <div id="footer">
417
- Generated on Tue Oct 1 21:19:36 2019 by
418
- <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
419
- 0.9.20 (ruby-2.5.5).
420
- </div>
421
-
422
- </div>
423
- </body>
424
- </html>
@@ -1,303 +0,0 @@
1
- (function() {
2
-
3
- var localStorage = {}, sessionStorage = {};
4
- try { localStorage = window.localStorage; } catch (e) { }
5
- try { sessionStorage = window.sessionStorage; } catch (e) { }
6
-
7
- function createSourceLinks() {
8
- $('.method_details_list .source_code').
9
- before("<span class='showSource'>[<a href='#' class='toggleSource'>View source</a>]</span>");
10
- $('.toggleSource').toggle(function() {
11
- $(this).parent().nextAll('.source_code').slideDown(100);
12
- $(this).text("Hide source");
13
- },
14
- function() {
15
- $(this).parent().nextAll('.source_code').slideUp(100);
16
- $(this).text("View source");
17
- });
18
- }
19
-
20
- function createDefineLinks() {
21
- var tHeight = 0;
22
- $('.defines').after(" <a href='#' class='toggleDefines'>more...</a>");
23
- $('.toggleDefines').toggle(function() {
24
- tHeight = $(this).parent().prev().height();
25
- $(this).prev().css('display', 'inline');
26
- $(this).parent().prev().height($(this).parent().height());
27
- $(this).text("(less)");
28
- },
29
- function() {
30
- $(this).prev().hide();
31
- $(this).parent().prev().height(tHeight);
32
- $(this).text("more...");
33
- });
34
- }
35
-
36
- function createFullTreeLinks() {
37
- var tHeight = 0;
38
- $('.inheritanceTree').toggle(function() {
39
- tHeight = $(this).parent().prev().height();
40
- $(this).parent().toggleClass('showAll');
41
- $(this).text("(hide)");
42
- $(this).parent().prev().height($(this).parent().height());
43
- },
44
- function() {
45
- $(this).parent().toggleClass('showAll');
46
- $(this).parent().prev().height(tHeight);
47
- $(this).text("show all");
48
- });
49
- }
50
-
51
- function searchFrameButtons() {
52
- $('.full_list_link').click(function() {
53
- toggleSearchFrame(this, $(this).attr('href'));
54
- return false;
55
- });
56
- window.addEventListener('message', function(e) {
57
- if (e.data === 'navEscape') {
58
- $('#nav').slideUp(100);
59
- $('#search a').removeClass('active inactive');
60
- $(window).focus();
61
- }
62
- });
63
-
64
- $(window).resize(function() {
65
- if ($('#search:visible').length === 0) {
66
- $('#nav').removeAttr('style');
67
- $('#search a').removeClass('active inactive');
68
- $(window).focus();
69
- }
70
- });
71
- }
72
-
73
- function toggleSearchFrame(id, link) {
74
- var frame = $('#nav');
75
- $('#search a').removeClass('active').addClass('inactive');
76
- if (frame.attr('src') === link && frame.css('display') !== "none") {
77
- frame.slideUp(100);
78
- $('#search a').removeClass('active inactive');
79
- }
80
- else {
81
- $(id).addClass('active').removeClass('inactive');
82
- if (frame.attr('src') !== link) frame.attr('src', link);
83
- frame.slideDown(100);
84
- }
85
- }
86
-
87
- function linkSummaries() {
88
- $('.summary_signature').click(function() {
89
- document.location = $(this).find('a').attr('href');
90
- });
91
- }
92
-
93
- function summaryToggle() {
94
- $('.summary_toggle').click(function(e) {
95
- e.preventDefault();
96
- localStorage.summaryCollapsed = $(this).text();
97
- $('.summary_toggle').each(function() {
98
- $(this).text($(this).text() == "collapse" ? "expand" : "collapse");
99
- var next = $(this).parent().parent().nextAll('ul.summary').first();
100
- if (next.hasClass('compact')) {
101
- next.toggle();
102
- next.nextAll('ul.summary').first().toggle();
103
- }
104
- else if (next.hasClass('summary')) {
105
- var list = $('<ul class="summary compact" />');
106
- list.html(next.html());
107
- list.find('.summary_desc, .note').remove();
108
- list.find('a').each(function() {
109
- $(this).html($(this).find('strong').html());
110
- $(this).parent().html($(this)[0].outerHTML);
111
- });
112
- next.before(list);
113
- next.toggle();
114
- }
115
- });
116
- return false;
117
- });
118
- if (localStorage.summaryCollapsed == "collapse") {
119
- $('.summary_toggle').first().click();
120
- } else { localStorage.summaryCollapsed = "expand"; }
121
- }
122
-
123
- function constantSummaryToggle() {
124
- $('.constants_summary_toggle').click(function(e) {
125
- e.preventDefault();
126
- localStorage.summaryCollapsed = $(this).text();
127
- $('.constants_summary_toggle').each(function() {
128
- $(this).text($(this).text() == "collapse" ? "expand" : "collapse");
129
- var next = $(this).parent().parent().nextAll('dl.constants').first();
130
- if (next.hasClass('compact')) {
131
- next.toggle();
132
- next.nextAll('dl.constants').first().toggle();
133
- }
134
- else if (next.hasClass('constants')) {
135
- var list = $('<dl class="constants compact" />');
136
- list.html(next.html());
137
- list.find('dt').each(function() {
138
- $(this).addClass('summary_signature');
139
- $(this).text( $(this).text().split('=')[0]);
140
- if ($(this).has(".deprecated").length) {
141
- $(this).addClass('deprecated');
142
- };
143
- });
144
- // Add the value of the constant as "Tooltip" to the summary object
145
- list.find('pre.code').each(function() {
146
- console.log($(this).parent());
147
- var dt_element = $(this).parent().prev();
148
- var tooltip = $(this).text();
149
- if (dt_element.hasClass("deprecated")) {
150
- tooltip = 'Deprecated. ' + tooltip;
151
- };
152
- dt_element.attr('title', tooltip);
153
- });
154
- list.find('.docstring, .tags, dd').remove();
155
- next.before(list);
156
- next.toggle();
157
- }
158
- });
159
- return false;
160
- });
161
- if (localStorage.summaryCollapsed == "collapse") {
162
- $('.constants_summary_toggle').first().click();
163
- } else { localStorage.summaryCollapsed = "expand"; }
164
- }
165
-
166
- function generateTOC() {
167
- if ($('#filecontents').length === 0) return;
168
- var _toc = $('<ol class="top"></ol>');
169
- var show = false;
170
- var toc = _toc;
171
- var counter = 0;
172
- var tags = ['h2', 'h3', 'h4', 'h5', 'h6'];
173
- var i;
174
- if ($('#filecontents h1').length > 1) tags.unshift('h1');
175
- for (i = 0; i < tags.length; i++) { tags[i] = '#filecontents ' + tags[i]; }
176
- var lastTag = parseInt(tags[0][1], 10);
177
- $(tags.join(', ')).each(function() {
178
- if ($(this).parents('.method_details .docstring').length != 0) return;
179
- if (this.id == "filecontents") return;
180
- show = true;
181
- var thisTag = parseInt(this.tagName[1], 10);
182
- if (this.id.length === 0) {
183
- var proposedId = $(this).attr('toc-id');
184
- if (typeof(proposedId) != "undefined") this.id = proposedId;
185
- else {
186
- var proposedId = $(this).text().replace(/[^a-z0-9-]/ig, '_');
187
- if ($('#' + proposedId).length > 0) { proposedId += counter; counter++; }
188
- this.id = proposedId;
189
- }
190
- }
191
- if (thisTag > lastTag) {
192
- for (i = 0; i < thisTag - lastTag; i++) {
193
- var tmp = $('<ol/>'); toc.append(tmp); toc = tmp;
194
- }
195
- }
196
- if (thisTag < lastTag) {
197
- for (i = 0; i < lastTag - thisTag; i++) toc = toc.parent();
198
- }
199
- var title = $(this).attr('toc-title');
200
- if (typeof(title) == "undefined") title = $(this).text();
201
- toc.append('<li><a href="#' + this.id + '">' + title + '</a></li>');
202
- lastTag = thisTag;
203
- });
204
- if (!show) return;
205
- html = '<div id="toc"><p class="title hide_toc"><a href="#"><strong>Table of Contents</strong></a></p></div>';
206
- $('#content').prepend(html);
207
- $('#toc').append(_toc);
208
- $('#toc .hide_toc').toggle(function() {
209
- $('#toc .top').slideUp('fast');
210
- $('#toc').toggleClass('hidden');
211
- $('#toc .title small').toggle();
212
- }, function() {
213
- $('#toc .top').slideDown('fast');
214
- $('#toc').toggleClass('hidden');
215
- $('#toc .title small').toggle();
216
- });
217
- }
218
-
219
- function navResizeFn(e) {
220
- if (e.which !== 1) {
221
- navResizeFnStop();
222
- return;
223
- }
224
-
225
- sessionStorage.navWidth = e.pageX.toString();
226
- $('.nav_wrap').css('width', e.pageX);
227
- $('.nav_wrap').css('-ms-flex', 'inherit');
228
- }
229
-
230
- function navResizeFnStop() {
231
- $(window).unbind('mousemove', navResizeFn);
232
- window.removeEventListener('message', navMessageFn, false);
233
- }
234
-
235
- function navMessageFn(e) {
236
- if (e.data.action === 'mousemove') navResizeFn(e.data.event);
237
- if (e.data.action === 'mouseup') navResizeFnStop();
238
- }
239
-
240
- function navResizer() {
241
- $('#resizer').mousedown(function(e) {
242
- e.preventDefault();
243
- $(window).mousemove(navResizeFn);
244
- window.addEventListener('message', navMessageFn, false);
245
- });
246
- $(window).mouseup(navResizeFnStop);
247
-
248
- if (sessionStorage.navWidth) {
249
- navResizeFn({which: 1, pageX: parseInt(sessionStorage.navWidth, 10)});
250
- }
251
- }
252
-
253
- function navExpander() {
254
- var done = false, timer = setTimeout(postMessage, 500);
255
- function postMessage() {
256
- if (done) return;
257
- clearTimeout(timer);
258
- var opts = { action: 'expand', path: pathId };
259
- document.getElementById('nav').contentWindow.postMessage(opts, '*');
260
- done = true;
261
- }
262
-
263
- window.addEventListener('message', function(event) {
264
- if (event.data === 'navReady') postMessage();
265
- return false;
266
- }, false);
267
- }
268
-
269
- function mainFocus() {
270
- var hash = window.location.hash;
271
- if (hash !== '' && $(hash)[0]) {
272
- $(hash)[0].scrollIntoView();
273
- }
274
-
275
- setTimeout(function() { $('#main').focus(); }, 10);
276
- }
277
-
278
- function navigationChange() {
279
- // This works around the broken anchor navigation with the YARD template.
280
- window.onpopstate = function() {
281
- var hash = window.location.hash;
282
- if (hash !== '' && $(hash)[0]) {
283
- $(hash)[0].scrollIntoView();
284
- }
285
- };
286
- }
287
-
288
- $(document).ready(function() {
289
- navResizer();
290
- navExpander();
291
- createSourceLinks();
292
- createDefineLinks();
293
- createFullTreeLinks();
294
- searchFrameButtons();
295
- linkSummaries();
296
- summaryToggle();
297
- constantSummaryToggle();
298
- generateTOC();
299
- mainFocus();
300
- navigationChange();
301
- });
302
-
303
- })();