[go: up one dir, main page]

0% found this document useful (0 votes)
42 views2 pages

DHHTML

This document contains code for implementing Diffie-Hellman key exchange. It includes a function that takes in prime numbers, private keys, and calculates public and secret keys. The function is called when a user clicks "Calculate" after entering the necessary values into a web form with fields for the prime number, primitive root, private keys, and output fields to display the public and secret keys.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views2 pages

DHHTML

This document contains code for implementing Diffie-Hellman key exchange. It includes a function that takes in prime numbers, private keys, and calculates public and secret keys. The function is called when a user clicks "Calculate" after entering the necessary values into a web form with fields for the prime number, primitive root, private keys, and output fields to display the public and secret keys.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

diffiehellman.

html 25-02-2020 09:33

1 <html>
2 <head>
3 <title>Diffie Hellman</title>
4 <script type="text/javascript">
5 function dh()
6 {
7 var p=document.f1.prime.value;
8 var pr=document.f1.primitive.value;
9 var xa=document.f1.aprivate.value;
10 var xb=document.f1.bprivate.value;
11 var ya=Math.pow(pr,xa)%p;
12 var yb=Math.pow(pr,xb)%p;
13 var ka=Math.pow(ya,xb)%p;
14 var kb=Math.pow(yb,xa)%p;
15 f1.apublic.value=ya;
16 f1.bpublic.value=yb;
17 f1.asecret.value=ka;
18 f1.bsecret.value=kb;
19
20 document.getElementById("ap").readOnly = true;
21 document.getElementById("bp").readOnly = true;
22 document.getElementById("as").readOnly = true;
23 document.getElementById("bs").readOnly = true;
24 }
25 </script>
26 </head>
27 <body>
28 <center>
29 <h1>DIFFIE HELLMAN KEY EXCHANGE</h1>
30 <table>
31
32 <form name="f1">
33 <tr><td>Enter prime number:</td><td><input type="text"
name="prime"/></td></tr>
34
35 <tr><td>Enter primitive root:</td><td><input type="text"
name="primitive"/></td></tr>
36
37 <tr><td>Enter the Xa private key:</td><td><input type="text"
name="aprivate"/></td></tr>
38
39 <tr><td>Enter the Xb private key:</td><td><input type="text"
name="bprivate"/></td></tr>
40
41 <tr><td>&nbsp</td><td><input type="Button" value="Calculate"
OnClick="dh()"/></td></tr>
42
43 <tr><td>Ya public key:</td><td><input type="text" name="apublic"
id="ap"/></td></tr>
44

Page 1 of 2
diffiehellman.html 25-02-2020 09:33

45 <tr><td>Yb public key:</td><td><input type="text" name="bpublic"


id="bp"/></td></tr>
46
47 <tr><td>ka secret key:</td><td><input type="text" name="asecret"
id="as"/></td></tr>
48
49 <tr><td>kb secret key:</td><td><input type="text" name="bsecret"
id="bs"/></td></tr>
50
51
52 <tr><td>&nbsp</td><td><input type="reset" name="Reset"/></td></tr>
53 </center>
54 </body>
55 </html>
56
57

Page 2 of 2

You might also like