-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.html
243 lines (243 loc) · 12.4 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
<!DOCTYPE html>
<html>
<head>
<title>RSA encryption, decryption and prime calculator</title>
<link rel="stylesheet" type="text/css" href="style.css"/>
<script type="text/javascript" src="js/LAB.js"></script>
<script type="text/JavaScript">
/* <![CDATA[ */
$LAB
.script("js/biginteger.js").wait()
.script("js/CommonFunctions.js").wait()
.script("js/Prime.js").wait()
.script("js/Decryptor.js")
.script("js/PrimeCalculator.js").wait()
.script("js/main.js")
.wait(function () {
load();
});
/* ]]> */
</script>
<!-- icons -->
<link rel="apple-touch-icon" sizes="57x57" href="icons/apple-touch-icon-57x57.png">
<link rel="apple-touch-icon" sizes="114x114" href="icons/apple-touch-icon-114x114.png">
<link rel="apple-touch-icon" sizes="72x72" href="icons/apple-touch-icon-72x72.png">
<link rel="apple-touch-icon" sizes="144x144" href="icons/apple-touch-icon-144x144.png">
<link rel="apple-touch-icon" sizes="60x60" href="icons/apple-touch-icon-60x60.png">
<link rel="apple-touch-icon" sizes="120x120" href="icons/apple-touch-icon-120x120.png">
<link rel="apple-touch-icon" sizes="76x76" href="icons/apple-touch-icon-76x76.png">
<link rel="apple-touch-icon" sizes="152x152" href="icons/apple-touch-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="icons/apple-touch-icon-180x180.png">
<link rel="shortcut icon" href="icons/favicon.ico">
<link rel="icon" type="image/png" href="icons/favicon-192x192.png" sizes="192x192">
<link rel="icon" type="image/png" href="icons/favicon-160x160.png" sizes="160x160">
<link rel="icon" type="image/png" href="icons/favicon-96x96.png" sizes="96x96">
<link rel="icon" type="image/png" href="icons/favicon-16x16.png" sizes="16x16">
<link rel="icon" type="image/png" href="icons/favicon-32x32.png" sizes="32x32">
<meta name="msapplication-TileColor" content="#fcf323">
<meta name="msapplication-TileImage" content="icons/mstile-144x144.png">
<meta name="msapplication-config" content="icons/browserconfig.xml">
</head>
<body>
<ul id="panel">
<li class="active"><a href="#intro" onclick="toggle(this);">Introduction</a></li>
<li><a href="#calculate" onclick="toggle(this);">Calculate primes</a></li>
<li><a href="#encrypt" onclick="toggle(this);">RSA Encryption</a></li>
<li><a href="#decrypt" onclick="toggle(this);">RSA Decryption</a></li>
<li><a href="#examples" onclick="toggle(this);">Examples</a></li>
</ul>
<div id="panels">
<div class="active">
<h1>RSA encryption, decryption and prime calculator</h1>
<p>This is a little tool I wrote a little while ago during a course that explained how RSA works. The course
wasn't just theoretical, but we also needed to decrypt simple RSA messages. Given that I don't like
repetitive tasks, my decision to automate the decryption was quickly made. Feel free to take a look at the
code to see how it works.</p>
<p>With this tool you'll be able to calculate primes, encrypt and decrypt message(s) using the RSA algorithm.</p>
<p>Currently all the primes between <span id="supportStart">0</span> and <span id="supportEnd">0</span> are
stored in a bunch of javascript files, so those can be used to encrypt or decrypt (after they are
dynamically loaded). In case this isn't sufficient, you can generate additional primes, which will be
preserved until the page reloads.</p>
<p>If you encounter any issues or have suggestions/improvements, please create a new
<a target="_blank" href="https://github.com/canihavesomecoffee/js-rsa-tool/issues/new">issue</a> on the
<a target="_blank" href="https://github.com/canihavesomecoffee/js-rsa-tool">GitHub project page</a>.</p>
<p>If you are interested in my personal site, you can visit it on
<a target="_blank" href="http://www.canihavesome.coffee">canihavesome.cofffee</a>.</p>
<h3>Acknowledgments</h3>
<p>I haven't written every line of code that's being used to show and generate this tool myself. I'd like to thank:</p>
<ul>
<li>Matthew Crumley and other contributors for the <a target="_blank" href="https://github.com/silentmatt/javascript-biginteger">BigInteger</a> js library</li>
<li>Kyle Simpson for the <a target="_blank" href="https://github.com/getify/LABjs">LABjs</a> library</li>
</ul>
</div>
<div>
<h1>Calculate primes</h1>
<p>Below you can <span class="strike-through">calculate</span> brute-force all the primes between a given lower
and upper bound. Once that's finished, it will show all the prime numbers in the text box. If you want some
explanation why a given number is not a prime number, tick the box, and an explanation will be shown for
that number.</p>
<table class="no-borders">
<tr>
<td><label for="startwith">From</label>:</td>
<td><input type="text" id="startwith" /></td>
</tr>
<tr>
<td><label for="endwith">To</label>:</td>
<td><input type="text" id="endwith" /></td>
</tr>
<tr>
<td><label for="shouldExplain">Explain the results</label>?</td>
<td>
<input type="checkbox" id="shouldExplain"/>
(WARNING! Causes severe lag/unresponsiveness with big ranges)
</td>
</tr>
<tr>
<td colspan="2">
<input type="button" value="Calculate primes" onclick="calc();"/>
<input type="button" value="Clear" onclick="clearcalc();"/>
</td>
</tr>
<tr>
<td colspan="2">
<label for="resultCalc">Found primes</label>:<br/>
<textarea id="resultCalc" cols="100" rows="5"></textarea>
</td>
</tr>
</table>
<p>Explanations:</p>
<div id="explain"></div>
</div>
<div>
<h1>RSA Encryption</h1>
<p>Here you can create an RSA encrypted message by filling in the form.</p>
<p><label for="p">First prime</label>: <input type="text" id="p"/> <label for="q">Second prime</label>: <input type="text" id="q"/> or
<input type="button" value="Pick two random primes" onclick="generateRandom();" /></p>
<p><label for="publice">Choose e, so that GCD(e,K) is 1</label>: <input type="text" id="publice"/></p>
<p><label for="toEncrypt">Plain-text message</label>: <br/><textarea id="toEncrypt" cols="20" rows="5"></textarea></p>
<p>
<input type="button" value="Start encryption" onclick="handleEncryption();" />
<input type="button" value="Clear results" onclick="document.getElementById('resultEn').innerHTML = ''; document.getElementById('statusEn').textContent = 'Not started yet.';" />
</p>
<p>Status: <span id="statusEn">Not started yet.</span></p>
<div id="resultEn"></div>
</div>
<div>
<h1>RSA Decryption</h1>
<p>Here you can try to brute-force and decrypt a given RSA message if you have the public key (N and e) and the
message.</p>
<p>Public key: <br/><label for="n">N</label>: <input type="text" id="n"/> <label for="e">e</label>: <input type="text" id="e"/></p>
<p><label for="message">Message</label><br/><textarea id="message" cols="20" rows="5"></textarea></p>
<p>
<input type="button" value="Start decryption" onclick="handleDecryption();" />
<input type="button" value="Clear results" onclick="document.getElementById('result').innerHTML = ''; document.getElementById('status').textContent = 'not started yet.';" />
</p>
<p>Progress: <span id="status">not started yet.</span></p>
<div id="result"></div>
</div>
<div>
<h1>Example tab</h1>
<p>This page lists a couple of examples which you can use on the other tabs.</p>
<table class="example">
<tr>
<td>Original message</td>
<td>Bewijs gevonden</td>
</tr>
<tr>
<td>N</td>
<td>69647</td>
</tr>
<tr>
<td>e</td>
<td>53</td>
</tr>
<tr>
<td>Encoded bits</td>
<td>
0011000100011010101010101001001000011011110110111110101000111111000100111101101011011011110111010000110101010110011100000111000001111101
</td>
</tr>
</table>
<table class="example">
<tr>
<td>Original message</td>
<td>Here you can create an RSA message, if you provide some information.</td>
</tr>
<tr>
<td>N</td>
<td>148730576801</td>
</tr>
<tr>
<td>e</td>
<td>13</td>
</tr>
<tr>
<td>Encoded bits</td>
<td>
0101101010110110111111011000111110111000001101011001010001101101101100010000001011111111110100011001101001101011100111101000011010001111000000101100101000110001111101111000101100110110100100011110011110010000000000100100101101000000010000001010111011101111110011101101001000011001001000101111011001000110010001001000010011111100111001011111010000011101011011011011110100001111101100011001111101110000101100100000110000000110101000010101101000111000101100110100111000110111010000010001101111101000110101001010101011101011101000000001010011110110111001110111111110001100000110110001010000101111100000010101100100000001011010100110000111101100110000
</td>
</tr>
</table>
<table class="example">
<tr>
<td>Original message</td>
<td>© 2013-now Willem Van Iseghem (wforums.net), all rights reserved.</td>
</tr>
<tr>
<td>N</td>
<td>928704363481</td>
</tr>
<tr>
<td>e</td>
<td>97</td>
</tr>
<tr>
<td>Encoded bits</td>
<td>
0100100110111111101011101100010100000011001100011100000110101001011100000010101110001001110010100111000010001101101011011000101101000111101100100011010101101000100011010110010001000111011101110011101111001100011100010001111111101010001111110111000000100011011110000110101000000000010101001101001101110110100100011111101110100101000100011010110101000111100011010101110011001011111100100110011011110010100001010110011111100111001101100001011110001000110110110010001101001110001111011001111101001101011011110011000111111110
</td>
</tr>
</table>
<table class="example">
<tr>
<td>Original message</td>
<td>Bewijs gevonden</td>
</tr>
<tr>
<td>N</td>
<td>999962000357</td>
</tr>
<tr>
<td>e</td>
<td>53</td>
</tr>
<tr>
<td>Encoded bits</td>
<td>
011111001011110101001000011101110110101100101110010000100010000110000011001110011101001110010001100110101101000110101110
</td>
</tr>
</table>
</div>
</div>
<div id="primestatus">
<span id="primestatusspan">No primes loaded.</span>
</div>
<div id="copy">© 2013-now Willem Van Iseghem (Can I Have Some Coffee), all rights reserved. Hosted on GitHub.</div>
<!-- Piwik -->
<script type="text/javascript">
var _paq = _paq || [];
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//piwik.canihavesome.coffee/";
_paq.push(['setTrackerUrl', u+'piwik.php']);
_paq.push(['setSiteId', 6]);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<noscript><p><img src="//piwik.canihavesome.coffee/piwik.php?idsite=6" style="border:0;" alt="" /></p></noscript>
<!-- End Piwik Code -->
</body>
</html>