blackbox 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +15 -0
  3. data/.rspec +2 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +374 -0
  6. data/README.md +34 -0
  7. data/Rakefile +31 -0
  8. data/blackbox.gemspec +25 -0
  9. data/coverage/.last_run.json +5 -0
  10. data/coverage/.resultset.json +323 -0
  11. data/coverage/assets/0.7.1/application.css +1110 -0
  12. data/coverage/assets/0.7.1/application.js +626 -0
  13. data/coverage/assets/0.7.1/fancybox/blank.gif +0 -0
  14. data/coverage/assets/0.7.1/fancybox/fancy_close.png +0 -0
  15. data/coverage/assets/0.7.1/fancybox/fancy_loading.png +0 -0
  16. data/coverage/assets/0.7.1/fancybox/fancy_nav_left.png +0 -0
  17. data/coverage/assets/0.7.1/fancybox/fancy_nav_right.png +0 -0
  18. data/coverage/assets/0.7.1/fancybox/fancy_shadow_e.png +0 -0
  19. data/coverage/assets/0.7.1/fancybox/fancy_shadow_n.png +0 -0
  20. data/coverage/assets/0.7.1/fancybox/fancy_shadow_ne.png +0 -0
  21. data/coverage/assets/0.7.1/fancybox/fancy_shadow_nw.png +0 -0
  22. data/coverage/assets/0.7.1/fancybox/fancy_shadow_s.png +0 -0
  23. data/coverage/assets/0.7.1/fancybox/fancy_shadow_se.png +0 -0
  24. data/coverage/assets/0.7.1/fancybox/fancy_shadow_sw.png +0 -0
  25. data/coverage/assets/0.7.1/fancybox/fancy_shadow_w.png +0 -0
  26. data/coverage/assets/0.7.1/fancybox/fancy_title_left.png +0 -0
  27. data/coverage/assets/0.7.1/fancybox/fancy_title_main.png +0 -0
  28. data/coverage/assets/0.7.1/fancybox/fancy_title_over.png +0 -0
  29. data/coverage/assets/0.7.1/fancybox/fancy_title_right.png +0 -0
  30. data/coverage/assets/0.7.1/fancybox/fancybox-x.png +0 -0
  31. data/coverage/assets/0.7.1/fancybox/fancybox-y.png +0 -0
  32. data/coverage/assets/0.7.1/fancybox/fancybox.png +0 -0
  33. data/coverage/assets/0.7.1/favicon_green.png +0 -0
  34. data/coverage/assets/0.7.1/favicon_red.png +0 -0
  35. data/coverage/assets/0.7.1/favicon_yellow.png +0 -0
  36. data/coverage/assets/0.7.1/loading.gif +0 -0
  37. data/coverage/assets/0.7.1/magnify.png +0 -0
  38. data/coverage/assets/0.7.1/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  39. data/coverage/assets/0.7.1/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  40. data/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  41. data/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  42. data/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  43. data/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  44. data/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  45. data/coverage/assets/0.7.1/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  46. data/coverage/assets/0.7.1/smoothness/images/ui-icons_222222_256x240.png +0 -0
  47. data/coverage/assets/0.7.1/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
  48. data/coverage/assets/0.7.1/smoothness/images/ui-icons_454545_256x240.png +0 -0
  49. data/coverage/assets/0.7.1/smoothness/images/ui-icons_888888_256x240.png +0 -0
  50. data/coverage/assets/0.7.1/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
  51. data/coverage/index.html +2080 -0
  52. data/doc/BB.html +129 -0
  53. data/doc/BB/Crypto.html +1145 -0
  54. data/doc/BB/Hash.html +441 -0
  55. data/doc/BB/String.html +240 -0
  56. data/doc/_index.html +155 -0
  57. data/doc/class_list.html +53 -0
  58. data/doc/css/common.css +1 -0
  59. data/doc/css/full_list.css +57 -0
  60. data/doc/css/style.css +338 -0
  61. data/doc/file.README.html +104 -0
  62. data/doc/file_list.html +55 -0
  63. data/doc/frames.html +28 -0
  64. data/doc/index.html +104 -0
  65. data/doc/js/app.js +214 -0
  66. data/doc/js/full_list.js +173 -0
  67. data/doc/js/jquery.js +4 -0
  68. data/doc/method_list.html +124 -0
  69. data/doc/top-level-namespace.html +112 -0
  70. data/lib/blackbox.rb +4 -0
  71. data/lib/blackbox/crypto.rb +99 -0
  72. data/lib/blackbox/hash.rb +49 -0
  73. data/lib/blackbox/string.rb +17 -0
  74. data/lib/blackbox/version.rb +3 -0
  75. data/spec/blackbox_spec.rb +9 -0
  76. data/spec/crypto_spec.rb +70 -0
  77. data/spec/hash_spec.rb +51 -0
  78. data/spec/spec_helper.rb +4 -0
  79. data/spec/string_spec.rb +13 -0
  80. metadata +184 -0
@@ -0,0 +1,129 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
+ <title>
7
+ Module: BB
8
+
9
+ &mdash; Documentation by YARD 0.8.5.2
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" media="screen" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ hasFrames = window.top.frames.main ? true : false;
19
+ relpath = '';
20
+ framesUrl = "frames.html#!" + escape(window.location.href);
21
+ </script>
22
+
23
+
24
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
25
+
26
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
27
+
28
+
29
+ </head>
30
+ <body>
31
+ <div id="header">
32
+ <div id="menu">
33
+
34
+ <a href="_index.html">Index (B)</a> &raquo;
35
+
36
+
37
+ <span class="title">BB</span>
38
+
39
+
40
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
41
+ </div>
42
+
43
+ <div id="search">
44
+
45
+ <a class="full_list_link" id="class_list_link"
46
+ href="class_list.html">
47
+ Class List
48
+ </a>
49
+
50
+ <a class="full_list_link" id="method_list_link"
51
+ href="method_list.html">
52
+ Method List
53
+ </a>
54
+
55
+ <a class="full_list_link" id="file_list_link"
56
+ href="file_list.html">
57
+ File List
58
+ </a>
59
+
60
+ </div>
61
+ <div class="clear"></div>
62
+ </div>
63
+
64
+ <iframe id="search_frame"></iframe>
65
+
66
+ <div id="content"><h1>Module: BB
67
+
68
+
69
+
70
+ </h1>
71
+
72
+ <dl class="box">
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+ <dt class="r1 last">Defined in:</dt>
82
+ <dd class="r1 last">lib/blackbox/hash.rb<span class="defines">,<br />
83
+ lib/blackbox/string.rb,<br /> lib/blackbox/crypto.rb,<br /> lib/blackbox/version.rb</span>
84
+ </dd>
85
+
86
+ </dl>
87
+ <div class="clear"></div>
88
+
89
+ <h2>Defined Under Namespace</h2>
90
+ <p class="children">
91
+
92
+
93
+ <strong class="modules">Modules:</strong> <span class='object_link'><a href="BB/Crypto.html" title="BB::Crypto (module)">Crypto</a></span>, <span class='object_link'><a href="BB/Hash.html" title="BB::Hash (module)">Hash</a></span>, <span class='object_link'><a href="BB/String.html" title="BB::String (module)">String</a></span>
94
+
95
+
96
+
97
+
98
+ </p>
99
+
100
+ <h2>Constant Summary</h2>
101
+
102
+ <dl class="constants">
103
+
104
+ <dt id="VERSION-constant" class="">VERSION =
105
+
106
+ </dt>
107
+ <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>1.0.0</span><span class='tstring_end'>&quot;</span></span></pre></dd>
108
+
109
+ </dl>
110
+
111
+
112
+
113
+
114
+
115
+
116
+
117
+
118
+
119
+
120
+ </div>
121
+
122
+ <div id="footer">
123
+ Generated on Sat Mar 30 01:48:11 2013 by
124
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
125
+ 0.8.5.2 (ruby-2.0.0).
126
+ </div>
127
+
128
+ </body>
129
+ </html>
@@ -0,0 +1,1145 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
+ <title>
7
+ Module: BB::Crypto
8
+
9
+ &mdash; Documentation by YARD 0.8.5.2
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../css/style.css" type="text/css" media="screen" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="../css/common.css" type="text/css" media="screen" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ hasFrames = window.top.frames.main ? true : false;
19
+ relpath = '../';
20
+ framesUrl = "../frames.html#!" + escape(window.location.href);
21
+ </script>
22
+
23
+
24
+ <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
25
+
26
+ <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
27
+
28
+
29
+ </head>
30
+ <body>
31
+ <div id="header">
32
+ <div id="menu">
33
+
34
+ <a href="../_index.html">Index (C)</a> &raquo;
35
+ <span class='title'><span class='object_link'><a href="../BB.html" title="BB (module)">BB</a></span></span>
36
+ &raquo;
37
+ <span class="title">Crypto</span>
38
+
39
+
40
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
41
+ </div>
42
+
43
+ <div id="search">
44
+
45
+ <a class="full_list_link" id="class_list_link"
46
+ href="../class_list.html">
47
+ Class List
48
+ </a>
49
+
50
+ <a class="full_list_link" id="method_list_link"
51
+ href="../method_list.html">
52
+ Method List
53
+ </a>
54
+
55
+ <a class="full_list_link" id="file_list_link"
56
+ href="../file_list.html">
57
+ File List
58
+ </a>
59
+
60
+ </div>
61
+ <div class="clear"></div>
62
+ </div>
63
+
64
+ <iframe id="search_frame"></iframe>
65
+
66
+ <div id="content"><h1>Module: BB::Crypto
67
+
68
+
69
+
70
+ </h1>
71
+
72
+ <dl class="box">
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+ <dt class="r1 last">Defined in:</dt>
82
+ <dd class="r1 last">lib/blackbox/crypto.rb</dd>
83
+
84
+ </dl>
85
+ <div class="clear"></div>
86
+
87
+ <h2>Overview</h2><div class="docstring">
88
+ <div class="discussion">
89
+
90
+ <p>Crypto utilities.</p>
91
+
92
+
93
+ </div>
94
+ </div>
95
+ <div class="tags">
96
+
97
+
98
+ </div>
99
+
100
+
101
+
102
+
103
+
104
+
105
+
106
+ <h2>
107
+ Class Method Summary
108
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
109
+ </h2>
110
+
111
+ <ul class="summary">
112
+
113
+ <li class="public ">
114
+ <span class="summary_signature">
115
+
116
+ <a href="#decrypt-class_method" title="decrypt (class method)">+ (String) <strong>decrypt</strong>(ciphertext, key, cipher_type = &#39;aes-256-cbc&#39;, iv = nil) </a>
117
+
118
+
119
+
120
+ </span>
121
+
122
+
123
+
124
+
125
+
126
+
127
+
128
+
129
+
130
+ <span class="summary_desc"><div class='inline'>
131
+ <p>Decrypt a String.</p>
132
+ </div></span>
133
+
134
+ </li>
135
+
136
+
137
+ <li class="public ">
138
+ <span class="summary_signature">
139
+
140
+ <a href="#decrypt_base64-class_method" title="decrypt_base64 (class method)">+ (String) <strong>decrypt_base64</strong>(ciphertext, key, cipher_type = &#39;aes-256-cbc&#39;, iv = nil) </a>
141
+
142
+
143
+
144
+ </span>
145
+
146
+
147
+
148
+
149
+
150
+
151
+
152
+
153
+
154
+ <span class="summary_desc"><div class='inline'>
155
+ <p>Decode and Decrypt a Base64-String.</p>
156
+ </div></span>
157
+
158
+ </li>
159
+
160
+
161
+ <li class="public ">
162
+ <span class="summary_signature">
163
+
164
+ <a href="#decrypt_urlsafe_base64-class_method" title="decrypt_urlsafe_base64 (class method)">+ (String) <strong>decrypt_urlsafe_base64</strong>(ciphertext, key, cipher_type = &#39;aes-256-cbc&#39;, iv = nil) </a>
165
+
166
+
167
+
168
+ </span>
169
+
170
+
171
+
172
+
173
+
174
+
175
+
176
+
177
+
178
+ <span class="summary_desc"><div class='inline'>
179
+ <p>Decode and Decrypt an urlsafe Base64-String.</p>
180
+ </div></span>
181
+
182
+ </li>
183
+
184
+
185
+ <li class="public ">
186
+ <span class="summary_signature">
187
+
188
+ <a href="#encrypt-class_method" title="encrypt (class method)">+ (String) <strong>encrypt</strong>(plaintext, key, cipher_type = &#39;aes-256-cbc&#39;, iv = nil) </a>
189
+
190
+
191
+
192
+ </span>
193
+
194
+
195
+
196
+
197
+
198
+
199
+
200
+
201
+
202
+ <span class="summary_desc"><div class='inline'>
203
+ <p>Encrypt a String.</p>
204
+ </div></span>
205
+
206
+ </li>
207
+
208
+
209
+ <li class="public ">
210
+ <span class="summary_signature">
211
+
212
+ <a href="#encrypt_base64-class_method" title="encrypt_base64 (class method)">+ (String) <strong>encrypt_base64</strong>(plaintext, key, cipher_type = &#39;aes-256-cbc&#39;, iv = nil) </a>
213
+
214
+
215
+
216
+ </span>
217
+
218
+
219
+
220
+
221
+
222
+
223
+
224
+
225
+
226
+ <span class="summary_desc"><div class='inline'>
227
+ <p>Encrypt a String and encode the resulting ciphertext to Base64.</p>
228
+ </div></span>
229
+
230
+ </li>
231
+
232
+
233
+ <li class="public ">
234
+ <span class="summary_signature">
235
+
236
+ <a href="#encrypt_urlsafe_base64-class_method" title="encrypt_urlsafe_base64 (class method)">+ (String) <strong>encrypt_urlsafe_base64</strong>(plaintext, key, cipher_type = &#39;aes-256-cbc&#39;, iv = nil) </a>
237
+
238
+
239
+
240
+ </span>
241
+
242
+
243
+
244
+
245
+
246
+
247
+
248
+
249
+
250
+ <span class="summary_desc"><div class='inline'>
251
+ <p>Encrypt a String and encode the resulting ciphertext to urlsafe Base64.</p>
252
+ </div></span>
253
+
254
+ </li>
255
+
256
+
257
+ </ul>
258
+
259
+
260
+
261
+
262
+ <div id="class_method_details" class="method_details_list">
263
+ <h2>Class Method Details</h2>
264
+
265
+
266
+ <div class="method_details first">
267
+ <h3 class="signature first" id="decrypt-class_method">
268
+
269
+ + (<tt><span class='object_link'><a href="String.html" title="BB::String (module)">String</a></span></tt>) <strong>decrypt</strong>(ciphertext, key, cipher_type = &#39;aes-256-cbc&#39;, iv = nil)
270
+
271
+
272
+
273
+
274
+
275
+ </h3><div class="docstring">
276
+ <div class="discussion">
277
+
278
+ <p>Decrypt a String.</p>
279
+
280
+
281
+ </div>
282
+ </div>
283
+ <div class="tags">
284
+ <p class="tag_title">Parameters:</p>
285
+ <ul class="param">
286
+
287
+ <li>
288
+
289
+ <span class='name'>ciphertext</span>
290
+
291
+
292
+ <span class='type'>(<tt><span class='object_link'><a href="String.html" title="BB::String (module)">String</a></span></tt>)</span>
293
+
294
+
295
+
296
+ &mdash;
297
+ <div class='inline'>
298
+ <p>Input String (ciphertext)</p>
299
+ </div>
300
+
301
+ </li>
302
+
303
+ <li>
304
+
305
+ <span class='name'>key</span>
306
+
307
+
308
+ <span class='type'>(<tt><span class='object_link'><a href="String.html" title="BB::String (module)">String</a></span></tt>)</span>
309
+
310
+
311
+
312
+ &mdash;
313
+ <div class='inline'>
314
+ <p>Encryption key</p>
315
+ </div>
316
+
317
+ </li>
318
+
319
+ <li>
320
+
321
+ <span class='name'>cipher_type</span>
322
+
323
+
324
+ <span class='type'>(<tt><span class='object_link'><a href="String.html" title="BB::String (module)">String</a></span></tt>)</span>
325
+
326
+
327
+ <em class="default">(defaults to: <tt>&#39;aes-256-cbc&#39;</tt>)</em>
328
+
329
+
330
+ &mdash;
331
+ <div class='inline'>
332
+ <p>OpenSSL cipher</p>
333
+ </div>
334
+
335
+ </li>
336
+
337
+ <li>
338
+
339
+ <span class='name'>iv</span>
340
+
341
+
342
+ <span class='type'>(<tt><span class='object_link'><a href="String.html" title="BB::String (module)">String</a></span></tt>)</span>
343
+
344
+
345
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
346
+
347
+
348
+ &mdash;
349
+ <div class='inline'>
350
+ <p>Initialization vector</p>
351
+ </div>
352
+
353
+ </li>
354
+
355
+ </ul>
356
+
357
+ <p class="tag_title">Returns:</p>
358
+ <ul class="return">
359
+
360
+ <li>
361
+
362
+
363
+ <span class='type'>(<tt><span class='object_link'><a href="String.html" title="BB::String (module)">String</a></span></tt>)</span>
364
+
365
+
366
+
367
+ &mdash;
368
+ <div class='inline'>
369
+ <p>Plaintext</p>
370
+ </div>
371
+
372
+ </li>
373
+
374
+ </ul>
375
+
376
+ </div><table class="source_code">
377
+ <tr>
378
+ <td>
379
+ <pre class="lines">
380
+
381
+
382
+ 36
383
+ 37
384
+ 38
385
+ 39
386
+ 40
387
+ 41
388
+ 42
389
+ 43
390
+ 44
391
+ 45
392
+ 46
393
+ 47
394
+ 48
395
+ 49</pre>
396
+ </td>
397
+ <td>
398
+ <pre class="code"><span class="info file"># File 'lib/blackbox/crypto.rb', line 36</span>
399
+
400
+ <span class='kw'>def</span> <span class='id identifier rubyid_decrypt'>decrypt</span><span class='lparen'>(</span><span class='id identifier rubyid_ciphertext'>ciphertext</span><span class='comma'>,</span> <span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_cipher_type'>cipher_type</span><span class='op'>=</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>aes-256-cbc</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_iv'>iv</span><span class='op'>=</span><span class='kw'>nil</span><span class='rparen'>)</span>
401
+ <span class='id identifier rubyid_aes'>aes</span> <span class='op'>=</span> <span class='const'>OpenSSL</span><span class='op'>::</span><span class='const'>Cipher</span><span class='op'>::</span><span class='const'>Cipher</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_cipher_type'>cipher_type</span><span class='rparen'>)</span>
402
+ <span class='id identifier rubyid_aes'>aes</span><span class='period'>.</span><span class='id identifier rubyid_decrypt'>decrypt</span>
403
+ <span class='id identifier rubyid_aes'>aes</span><span class='period'>.</span><span class='id identifier rubyid_key'>key</span> <span class='op'>=</span> <span class='id identifier rubyid_key'>key</span>
404
+ <span class='kw'>if</span> <span class='id identifier rubyid_iv'>iv</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
405
+ <span class='id identifier rubyid_iv_len'>iv_len</span> <span class='op'>=</span> <span class='id identifier rubyid_ciphertext'>ciphertext</span><span class='period'>.</span><span class='id identifier rubyid_slice!'>slice!</span><span class='lparen'>(</span><span class='int'>0</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_unpack'>unpack</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>C</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span>
406
+ <span class='kw'>unless</span> <span class='int'>0</span> <span class='op'>==</span> <span class='id identifier rubyid_iv_len'>iv_len</span>
407
+ <span class='id identifier rubyid_aes'>aes</span><span class='period'>.</span><span class='id identifier rubyid_iv'>iv</span> <span class='op'>=</span> <span class='id identifier rubyid_ciphertext'>ciphertext</span><span class='period'>.</span><span class='id identifier rubyid_slice!'>slice!</span><span class='lparen'>(</span><span class='int'>0</span><span class='op'>..</span><span class='id identifier rubyid_iv_len'>iv_len</span><span class='op'>-</span><span class='int'>1</span><span class='rparen'>)</span>
408
+ <span class='kw'>end</span>
409
+ <span class='kw'>else</span>
410
+ <span class='id identifier rubyid_aes'>aes</span><span class='period'>.</span><span class='id identifier rubyid_iv'>iv</span> <span class='op'>=</span> <span class='id identifier rubyid_iv'>iv</span>
411
+ <span class='kw'>end</span>
412
+ <span class='id identifier rubyid_aes'>aes</span><span class='period'>.</span><span class='id identifier rubyid_update'>update</span><span class='lparen'>(</span><span class='id identifier rubyid_ciphertext'>ciphertext</span><span class='rparen'>)</span> <span class='op'>+</span> <span class='id identifier rubyid_aes'>aes</span><span class='period'>.</span><span class='id identifier rubyid_final'>final</span>
413
+ <span class='kw'>end</span></pre>
414
+ </td>
415
+ </tr>
416
+ </table>
417
+ </div>
418
+
419
+ <div class="method_details ">
420
+ <h3 class="signature " id="decrypt_base64-class_method">
421
+
422
+ + (<tt><span class='object_link'><a href="String.html" title="BB::String (module)">String</a></span></tt>) <strong>decrypt_base64</strong>(ciphertext, key, cipher_type = &#39;aes-256-cbc&#39;, iv = nil)
423
+
424
+
425
+
426
+
427
+
428
+ </h3><div class="docstring">
429
+ <div class="discussion">
430
+
431
+ <p>Decode and Decrypt a Base64-String.</p>
432
+
433
+
434
+ </div>
435
+ </div>
436
+ <div class="tags">
437
+ <p class="tag_title">Parameters:</p>
438
+ <ul class="param">
439
+
440
+ <li>
441
+
442
+ <span class='name'>ciphertext</span>
443
+
444
+
445
+ <span class='type'>(<tt><span class='object_link'><a href="String.html" title="BB::String (module)">String</a></span></tt>)</span>
446
+
447
+
448
+
449
+ &mdash;
450
+ <div class='inline'>
451
+ <p>Input String (base64(ciphertext))</p>
452
+ </div>
453
+
454
+ </li>
455
+
456
+ <li>
457
+
458
+ <span class='name'>key</span>
459
+
460
+
461
+ <span class='type'>(<tt><span class='object_link'><a href="String.html" title="BB::String (module)">String</a></span></tt>)</span>
462
+
463
+
464
+
465
+ &mdash;
466
+ <div class='inline'>
467
+ <p>Encryption key</p>
468
+ </div>
469
+
470
+ </li>
471
+
472
+ <li>
473
+
474
+ <span class='name'>cipher_type</span>
475
+
476
+
477
+ <span class='type'>(<tt><span class='object_link'><a href="String.html" title="BB::String (module)">String</a></span></tt>)</span>
478
+
479
+
480
+ <em class="default">(defaults to: <tt>&#39;aes-256-cbc&#39;</tt>)</em>
481
+
482
+
483
+ &mdash;
484
+ <div class='inline'>
485
+ <p>OpenSSL cipher</p>
486
+ </div>
487
+
488
+ </li>
489
+
490
+ <li>
491
+
492
+ <span class='name'>iv</span>
493
+
494
+
495
+ <span class='type'>(<tt><span class='object_link'><a href="String.html" title="BB::String (module)">String</a></span></tt>)</span>
496
+
497
+
498
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
499
+
500
+
501
+ &mdash;
502
+ <div class='inline'>
503
+ <p>Initialization vector</p>
504
+ </div>
505
+
506
+ </li>
507
+
508
+ </ul>
509
+
510
+ <p class="tag_title">Returns:</p>
511
+ <ul class="return">
512
+
513
+ <li>
514
+
515
+
516
+ <span class='type'>(<tt><span class='object_link'><a href="String.html" title="BB::String (module)">String</a></span></tt>)</span>
517
+
518
+
519
+
520
+ &mdash;
521
+ <div class='inline'>
522
+ <p>Plaintext</p>
523
+ </div>
524
+
525
+ </li>
526
+
527
+ </ul>
528
+
529
+ </div><table class="source_code">
530
+ <tr>
531
+ <td>
532
+ <pre class="lines">
533
+
534
+
535
+ 70
536
+ 71
537
+ 72</pre>
538
+ </td>
539
+ <td>
540
+ <pre class="code"><span class="info file"># File 'lib/blackbox/crypto.rb', line 70</span>
541
+
542
+ <span class='kw'>def</span> <span class='id identifier rubyid_decrypt_base64'>decrypt_base64</span><span class='lparen'>(</span><span class='id identifier rubyid_ciphertext'>ciphertext</span><span class='comma'>,</span> <span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_cipher_type'>cipher_type</span><span class='op'>=</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>aes-256-cbc</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_iv'>iv</span><span class='op'>=</span><span class='kw'>nil</span><span class='rparen'>)</span>
543
+ <span class='id identifier rubyid_decrypt'>decrypt</span><span class='lparen'>(</span><span class='const'>Base64</span><span class='period'>.</span><span class='id identifier rubyid_decode64'>decode64</span><span class='lparen'>(</span><span class='id identifier rubyid_ciphertext'>ciphertext</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_cipher_type'>cipher_type</span><span class='comma'>,</span> <span class='id identifier rubyid_iv'>iv</span><span class='rparen'>)</span>
544
+ <span class='kw'>end</span></pre>
545
+ </td>
546
+ </tr>
547
+ </table>
548
+ </div>
549
+
550
+ <div class="method_details ">
551
+ <h3 class="signature " id="decrypt_urlsafe_base64-class_method">
552
+
553
+ + (<tt><span class='object_link'><a href="String.html" title="BB::String (module)">String</a></span></tt>) <strong>decrypt_urlsafe_base64</strong>(ciphertext, key, cipher_type = &#39;aes-256-cbc&#39;, iv = nil)
554
+
555
+
556
+
557
+
558
+
559
+ </h3><div class="docstring">
560
+ <div class="discussion">
561
+
562
+ <p>Decode and Decrypt an urlsafe Base64-String.</p>
563
+
564
+
565
+ </div>
566
+ </div>
567
+ <div class="tags">
568
+ <p class="tag_title">Parameters:</p>
569
+ <ul class="param">
570
+
571
+ <li>
572
+
573
+ <span class='name'>ciphertext</span>
574
+
575
+
576
+ <span class='type'>(<tt><span class='object_link'><a href="String.html" title="BB::String (module)">String</a></span></tt>)</span>
577
+
578
+
579
+
580
+ &mdash;
581
+ <div class='inline'>
582
+ <p>Input String (urlsafe_base64(ciphertext))</p>
583
+ </div>
584
+
585
+ </li>
586
+
587
+ <li>
588
+
589
+ <span class='name'>key</span>
590
+
591
+
592
+ <span class='type'>(<tt><span class='object_link'><a href="String.html" title="BB::String (module)">String</a></span></tt>)</span>
593
+
594
+
595
+
596
+ &mdash;
597
+ <div class='inline'>
598
+ <p>Encryption key</p>
599
+ </div>
600
+
601
+ </li>
602
+
603
+ <li>
604
+
605
+ <span class='name'>cipher_type</span>
606
+
607
+
608
+ <span class='type'>(<tt><span class='object_link'><a href="String.html" title="BB::String (module)">String</a></span></tt>)</span>
609
+
610
+
611
+ <em class="default">(defaults to: <tt>&#39;aes-256-cbc&#39;</tt>)</em>
612
+
613
+
614
+ &mdash;
615
+ <div class='inline'>
616
+ <p>OpenSSL cipher</p>
617
+ </div>
618
+
619
+ </li>
620
+
621
+ <li>
622
+
623
+ <span class='name'>iv</span>
624
+
625
+
626
+ <span class='type'>(<tt><span class='object_link'><a href="String.html" title="BB::String (module)">String</a></span></tt>)</span>
627
+
628
+
629
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
630
+
631
+
632
+ &mdash;
633
+ <div class='inline'>
634
+ <p>Initialization vector</p>
635
+ </div>
636
+
637
+ </li>
638
+
639
+ </ul>
640
+
641
+ <p class="tag_title">Returns:</p>
642
+ <ul class="return">
643
+
644
+ <li>
645
+
646
+
647
+ <span class='type'>(<tt><span class='object_link'><a href="String.html" title="BB::String (module)">String</a></span></tt>)</span>
648
+
649
+
650
+
651
+ &mdash;
652
+ <div class='inline'>
653
+ <p>Plaintext</p>
654
+ </div>
655
+
656
+ </li>
657
+
658
+ </ul>
659
+
660
+ </div><table class="source_code">
661
+ <tr>
662
+ <td>
663
+ <pre class="lines">
664
+
665
+
666
+ 93
667
+ 94
668
+ 95</pre>
669
+ </td>
670
+ <td>
671
+ <pre class="code"><span class="info file"># File 'lib/blackbox/crypto.rb', line 93</span>
672
+
673
+ <span class='kw'>def</span> <span class='id identifier rubyid_decrypt_urlsafe_base64'>decrypt_urlsafe_base64</span><span class='lparen'>(</span><span class='id identifier rubyid_ciphertext'>ciphertext</span><span class='comma'>,</span> <span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_cipher_type'>cipher_type</span><span class='op'>=</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>aes-256-cbc</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_iv'>iv</span><span class='op'>=</span><span class='kw'>nil</span><span class='rparen'>)</span>
674
+ <span class='id identifier rubyid_decrypt'>decrypt</span><span class='lparen'>(</span><span class='const'>Base64</span><span class='period'>.</span><span class='id identifier rubyid_urlsafe_decode64'>urlsafe_decode64</span><span class='lparen'>(</span><span class='id identifier rubyid_ciphertext'>ciphertext</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_cipher_type'>cipher_type</span><span class='comma'>,</span> <span class='id identifier rubyid_iv'>iv</span><span class='rparen'>)</span>
675
+ <span class='kw'>end</span></pre>
676
+ </td>
677
+ </tr>
678
+ </table>
679
+ </div>
680
+
681
+ <div class="method_details ">
682
+ <h3 class="signature " id="encrypt-class_method">
683
+
684
+ + (<tt><span class='object_link'><a href="String.html" title="BB::String (module)">String</a></span></tt>) <strong>encrypt</strong>(plaintext, key, cipher_type = &#39;aes-256-cbc&#39;, iv = nil)
685
+
686
+
687
+
688
+
689
+
690
+ </h3><div class="docstring">
691
+ <div class="discussion">
692
+
693
+ <p>Encrypt a String.</p>
694
+
695
+
696
+ </div>
697
+ </div>
698
+ <div class="tags">
699
+ <p class="tag_title">Parameters:</p>
700
+ <ul class="param">
701
+
702
+ <li>
703
+
704
+ <span class='name'>plaintext</span>
705
+
706
+
707
+ <span class='type'>(<tt><span class='object_link'><a href="String.html" title="BB::String (module)">String</a></span></tt>)</span>
708
+
709
+
710
+
711
+ &mdash;
712
+ <div class='inline'>
713
+ <p>Input String (plaintext)</p>
714
+ </div>
715
+
716
+ </li>
717
+
718
+ <li>
719
+
720
+ <span class='name'>key</span>
721
+
722
+
723
+ <span class='type'>(<tt><span class='object_link'><a href="String.html" title="BB::String (module)">String</a></span></tt>)</span>
724
+
725
+
726
+
727
+ &mdash;
728
+ <div class='inline'>
729
+ <p>Encryption key</p>
730
+ </div>
731
+
732
+ </li>
733
+
734
+ <li>
735
+
736
+ <span class='name'>cipher_type</span>
737
+
738
+
739
+ <span class='type'>(<tt><span class='object_link'><a href="String.html" title="BB::String (module)">String</a></span></tt>)</span>
740
+
741
+
742
+ <em class="default">(defaults to: <tt>&#39;aes-256-cbc&#39;</tt>)</em>
743
+
744
+
745
+ &mdash;
746
+ <div class='inline'>
747
+ <p>OpenSSL cipher</p>
748
+ </div>
749
+
750
+ </li>
751
+
752
+ <li>
753
+
754
+ <span class='name'>iv</span>
755
+
756
+
757
+ <span class='type'>(<tt><span class='object_link'><a href="String.html" title="BB::String (module)">String</a></span></tt>)</span>
758
+
759
+
760
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
761
+
762
+
763
+ &mdash;
764
+ <div class='inline'>
765
+ <p>Initialization vector</p>
766
+ </div>
767
+
768
+ </li>
769
+
770
+ </ul>
771
+
772
+ <p class="tag_title">Returns:</p>
773
+ <ul class="return">
774
+
775
+ <li>
776
+
777
+
778
+ <span class='type'>(<tt><span class='object_link'><a href="String.html" title="BB::String (module)">String</a></span></tt>)</span>
779
+
780
+
781
+
782
+ &mdash;
783
+ <div class='inline'>
784
+ <p>When iv == nil: iv_length+iv+ciphertext</p>
785
+ </div>
786
+
787
+ </li>
788
+
789
+ <li>
790
+
791
+
792
+ <span class='type'>(<tt><span class='object_link'><a href="String.html" title="BB::String (module)">String</a></span></tt>)</span>
793
+
794
+
795
+
796
+ &mdash;
797
+ <div class='inline'>
798
+ <p>When iv != nil: ciphertext</p>
799
+ </div>
800
+
801
+ </li>
802
+
803
+ </ul>
804
+
805
+ </div><table class="source_code">
806
+ <tr>
807
+ <td>
808
+ <pre class="lines">
809
+
810
+
811
+ 16
812
+ 17
813
+ 18
814
+ 19
815
+ 20
816
+ 21
817
+ 22
818
+ 23
819
+ 24
820
+ 25
821
+ 26
822
+ 27</pre>
823
+ </td>
824
+ <td>
825
+ <pre class="code"><span class="info file"># File 'lib/blackbox/crypto.rb', line 16</span>
826
+
827
+ <span class='kw'>def</span> <span class='id identifier rubyid_encrypt'>encrypt</span><span class='lparen'>(</span><span class='id identifier rubyid_plaintext'>plaintext</span><span class='comma'>,</span> <span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_cipher_type'>cipher_type</span><span class='op'>=</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>aes-256-cbc</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_iv'>iv</span><span class='op'>=</span><span class='kw'>nil</span><span class='rparen'>)</span>
828
+ <span class='id identifier rubyid_aes'>aes</span> <span class='op'>=</span> <span class='const'>OpenSSL</span><span class='op'>::</span><span class='const'>Cipher</span><span class='op'>::</span><span class='const'>Cipher</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_cipher_type'>cipher_type</span><span class='rparen'>)</span>
829
+ <span class='id identifier rubyid_aes'>aes</span><span class='period'>.</span><span class='id identifier rubyid_encrypt'>encrypt</span>
830
+ <span class='id identifier rubyid_aes'>aes</span><span class='period'>.</span><span class='id identifier rubyid_key'>key</span> <span class='op'>=</span> <span class='id identifier rubyid_key'>key</span>
831
+ <span class='kw'>if</span> <span class='id identifier rubyid_iv'>iv</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
832
+ <span class='id identifier rubyid_iv'>iv</span> <span class='op'>=</span> <span class='id identifier rubyid_aes'>aes</span><span class='period'>.</span><span class='id identifier rubyid_random_iv'>random_iv</span>
833
+ <span class='lbracket'>[</span><span class='id identifier rubyid_iv'>iv</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_pack'>pack</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>C</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span> <span class='op'>+</span> <span class='id identifier rubyid_iv'>iv</span> <span class='op'>+</span> <span class='id identifier rubyid_aes'>aes</span><span class='period'>.</span><span class='id identifier rubyid_update'>update</span><span class='lparen'>(</span><span class='id identifier rubyid_plaintext'>plaintext</span><span class='rparen'>)</span> <span class='op'>+</span> <span class='id identifier rubyid_aes'>aes</span><span class='period'>.</span><span class='id identifier rubyid_final'>final</span>
834
+ <span class='kw'>else</span>
835
+ <span class='id identifier rubyid_aes'>aes</span><span class='period'>.</span><span class='id identifier rubyid_iv'>iv</span> <span class='op'>=</span> <span class='id identifier rubyid_iv'>iv</span>
836
+ <span class='id identifier rubyid_aes'>aes</span><span class='period'>.</span><span class='id identifier rubyid_update'>update</span><span class='lparen'>(</span><span class='id identifier rubyid_plaintext'>plaintext</span><span class='rparen'>)</span> <span class='op'>+</span> <span class='id identifier rubyid_aes'>aes</span><span class='period'>.</span><span class='id identifier rubyid_final'>final</span>
837
+ <span class='kw'>end</span>
838
+ <span class='kw'>end</span></pre>
839
+ </td>
840
+ </tr>
841
+ </table>
842
+ </div>
843
+
844
+ <div class="method_details ">
845
+ <h3 class="signature " id="encrypt_base64-class_method">
846
+
847
+ + (<tt><span class='object_link'><a href="String.html" title="BB::String (module)">String</a></span></tt>) <strong>encrypt_base64</strong>(plaintext, key, cipher_type = &#39;aes-256-cbc&#39;, iv = nil)
848
+
849
+
850
+
851
+
852
+
853
+ </h3><div class="docstring">
854
+ <div class="discussion">
855
+
856
+ <p>Encrypt a String and encode the resulting ciphertext to Base64.</p>
857
+
858
+
859
+ </div>
860
+ </div>
861
+ <div class="tags">
862
+ <p class="tag_title">Parameters:</p>
863
+ <ul class="param">
864
+
865
+ <li>
866
+
867
+ <span class='name'>plaintext</span>
868
+
869
+
870
+ <span class='type'>(<tt><span class='object_link'><a href="String.html" title="BB::String (module)">String</a></span></tt>)</span>
871
+
872
+
873
+
874
+ &mdash;
875
+ <div class='inline'>
876
+ <p>Input String (plaintext)</p>
877
+ </div>
878
+
879
+ </li>
880
+
881
+ <li>
882
+
883
+ <span class='name'>key</span>
884
+
885
+
886
+ <span class='type'>(<tt><span class='object_link'><a href="String.html" title="BB::String (module)">String</a></span></tt>)</span>
887
+
888
+
889
+
890
+ &mdash;
891
+ <div class='inline'>
892
+ <p>Encryption key</p>
893
+ </div>
894
+
895
+ </li>
896
+
897
+ <li>
898
+
899
+ <span class='name'>cipher_type</span>
900
+
901
+
902
+ <span class='type'>(<tt><span class='object_link'><a href="String.html" title="BB::String (module)">String</a></span></tt>)</span>
903
+
904
+
905
+ <em class="default">(defaults to: <tt>&#39;aes-256-cbc&#39;</tt>)</em>
906
+
907
+
908
+ &mdash;
909
+ <div class='inline'>
910
+ <p>OpenSSL cipher</p>
911
+ </div>
912
+
913
+ </li>
914
+
915
+ <li>
916
+
917
+ <span class='name'>iv</span>
918
+
919
+
920
+ <span class='type'>(<tt><span class='object_link'><a href="String.html" title="BB::String (module)">String</a></span></tt>)</span>
921
+
922
+
923
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
924
+
925
+
926
+ &mdash;
927
+ <div class='inline'>
928
+ <p>Initialization vector</p>
929
+ </div>
930
+
931
+ </li>
932
+
933
+ </ul>
934
+
935
+ <p class="tag_title">Returns:</p>
936
+ <ul class="return">
937
+
938
+ <li>
939
+
940
+
941
+ <span class='type'>(<tt><span class='object_link'><a href="String.html" title="BB::String (module)">String</a></span></tt>)</span>
942
+
943
+
944
+
945
+ &mdash;
946
+ <div class='inline'>
947
+ <p>When iv == nil: base64(iv_length+iv+ciphertext)</p>
948
+ </div>
949
+
950
+ </li>
951
+
952
+ <li>
953
+
954
+
955
+ <span class='type'>(<tt><span class='object_link'><a href="String.html" title="BB::String (module)">String</a></span></tt>)</span>
956
+
957
+
958
+
959
+ &mdash;
960
+ <div class='inline'>
961
+ <p>When iv != nil: base64(ciphertext)</p>
962
+ </div>
963
+
964
+ </li>
965
+
966
+ </ul>
967
+
968
+ </div><table class="source_code">
969
+ <tr>
970
+ <td>
971
+ <pre class="lines">
972
+
973
+
974
+ 59
975
+ 60
976
+ 61</pre>
977
+ </td>
978
+ <td>
979
+ <pre class="code"><span class="info file"># File 'lib/blackbox/crypto.rb', line 59</span>
980
+
981
+ <span class='kw'>def</span> <span class='id identifier rubyid_encrypt_base64'>encrypt_base64</span><span class='lparen'>(</span><span class='id identifier rubyid_plaintext'>plaintext</span><span class='comma'>,</span> <span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_cipher_type'>cipher_type</span><span class='op'>=</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>aes-256-cbc</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_iv'>iv</span><span class='op'>=</span><span class='kw'>nil</span><span class='rparen'>)</span>
982
+ <span class='const'>Base64</span><span class='period'>.</span><span class='id identifier rubyid_strict_encode64'>strict_encode64</span><span class='lparen'>(</span><span class='id identifier rubyid_encrypt'>encrypt</span><span class='lparen'>(</span><span class='id identifier rubyid_plaintext'>plaintext</span><span class='comma'>,</span> <span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_cipher_type'>cipher_type</span><span class='comma'>,</span> <span class='id identifier rubyid_iv'>iv</span><span class='rparen'>)</span><span class='rparen'>)</span>
983
+ <span class='kw'>end</span></pre>
984
+ </td>
985
+ </tr>
986
+ </table>
987
+ </div>
988
+
989
+ <div class="method_details ">
990
+ <h3 class="signature " id="encrypt_urlsafe_base64-class_method">
991
+
992
+ + (<tt><span class='object_link'><a href="String.html" title="BB::String (module)">String</a></span></tt>) <strong>encrypt_urlsafe_base64</strong>(plaintext, key, cipher_type = &#39;aes-256-cbc&#39;, iv = nil)
993
+
994
+
995
+
996
+
997
+
998
+ </h3><div class="docstring">
999
+ <div class="discussion">
1000
+
1001
+ <p>Encrypt a String and encode the resulting ciphertext to urlsafe Base64.</p>
1002
+
1003
+
1004
+ </div>
1005
+ </div>
1006
+ <div class="tags">
1007
+ <p class="tag_title">Parameters:</p>
1008
+ <ul class="param">
1009
+
1010
+ <li>
1011
+
1012
+ <span class='name'>plaintext</span>
1013
+
1014
+
1015
+ <span class='type'>(<tt><span class='object_link'><a href="String.html" title="BB::String (module)">String</a></span></tt>)</span>
1016
+
1017
+
1018
+
1019
+ &mdash;
1020
+ <div class='inline'>
1021
+ <p>Input String (plaintext)</p>
1022
+ </div>
1023
+
1024
+ </li>
1025
+
1026
+ <li>
1027
+
1028
+ <span class='name'>key</span>
1029
+
1030
+
1031
+ <span class='type'>(<tt><span class='object_link'><a href="String.html" title="BB::String (module)">String</a></span></tt>)</span>
1032
+
1033
+
1034
+
1035
+ &mdash;
1036
+ <div class='inline'>
1037
+ <p>Encryption key</p>
1038
+ </div>
1039
+
1040
+ </li>
1041
+
1042
+ <li>
1043
+
1044
+ <span class='name'>cipher_type</span>
1045
+
1046
+
1047
+ <span class='type'>(<tt><span class='object_link'><a href="String.html" title="BB::String (module)">String</a></span></tt>)</span>
1048
+
1049
+
1050
+ <em class="default">(defaults to: <tt>&#39;aes-256-cbc&#39;</tt>)</em>
1051
+
1052
+
1053
+ &mdash;
1054
+ <div class='inline'>
1055
+ <p>OpenSSL cipher</p>
1056
+ </div>
1057
+
1058
+ </li>
1059
+
1060
+ <li>
1061
+
1062
+ <span class='name'>iv</span>
1063
+
1064
+
1065
+ <span class='type'>(<tt><span class='object_link'><a href="String.html" title="BB::String (module)">String</a></span></tt>)</span>
1066
+
1067
+
1068
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
1069
+
1070
+
1071
+ &mdash;
1072
+ <div class='inline'>
1073
+ <p>Initialization vector</p>
1074
+ </div>
1075
+
1076
+ </li>
1077
+
1078
+ </ul>
1079
+
1080
+ <p class="tag_title">Returns:</p>
1081
+ <ul class="return">
1082
+
1083
+ <li>
1084
+
1085
+
1086
+ <span class='type'>(<tt><span class='object_link'><a href="String.html" title="BB::String (module)">String</a></span></tt>)</span>
1087
+
1088
+
1089
+
1090
+ &mdash;
1091
+ <div class='inline'>
1092
+ <p>When iv == nil: urlsafe_base64(iv_length+iv+ciphertext)</p>
1093
+ </div>
1094
+
1095
+ </li>
1096
+
1097
+ <li>
1098
+
1099
+
1100
+ <span class='type'>(<tt><span class='object_link'><a href="String.html" title="BB::String (module)">String</a></span></tt>)</span>
1101
+
1102
+
1103
+
1104
+ &mdash;
1105
+ <div class='inline'>
1106
+ <p>When iv != nil: urlsafe_base64(ciphertext)</p>
1107
+ </div>
1108
+
1109
+ </li>
1110
+
1111
+ </ul>
1112
+
1113
+ </div><table class="source_code">
1114
+ <tr>
1115
+ <td>
1116
+ <pre class="lines">
1117
+
1118
+
1119
+ 82
1120
+ 83
1121
+ 84</pre>
1122
+ </td>
1123
+ <td>
1124
+ <pre class="code"><span class="info file"># File 'lib/blackbox/crypto.rb', line 82</span>
1125
+
1126
+ <span class='kw'>def</span> <span class='id identifier rubyid_encrypt_urlsafe_base64'>encrypt_urlsafe_base64</span><span class='lparen'>(</span><span class='id identifier rubyid_plaintext'>plaintext</span><span class='comma'>,</span> <span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_cipher_type'>cipher_type</span><span class='op'>=</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>aes-256-cbc</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_iv'>iv</span><span class='op'>=</span><span class='kw'>nil</span><span class='rparen'>)</span>
1127
+ <span class='const'>Base64</span><span class='period'>.</span><span class='id identifier rubyid_urlsafe_encode64'>urlsafe_encode64</span><span class='lparen'>(</span><span class='id identifier rubyid_encrypt'>encrypt</span><span class='lparen'>(</span><span class='id identifier rubyid_plaintext'>plaintext</span><span class='comma'>,</span> <span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_cipher_type'>cipher_type</span><span class='comma'>,</span> <span class='id identifier rubyid_iv'>iv</span><span class='rparen'>)</span><span class='rparen'>)</span>
1128
+ <span class='kw'>end</span></pre>
1129
+ </td>
1130
+ </tr>
1131
+ </table>
1132
+ </div>
1133
+
1134
+ </div>
1135
+
1136
+ </div>
1137
+
1138
+ <div id="footer">
1139
+ Generated on Sat Mar 30 01:48:12 2013 by
1140
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1141
+ 0.8.5.2 (ruby-2.0.0).
1142
+ </div>
1143
+
1144
+ </body>
1145
+ </html>