Diffie–Hellman key exchange agreement

Hi,

I'm in the process of making a Diffie–Hellman algorithm and I actually got stuck how to do the key exchange agreement between both web sites. The website (ReqData.html) takes the info from the user and encrypts it and posts the encrypted info to the website (SendData.php) to decrypts it. The difficult point for me was how to put the agreement in ReqData.html using javascript and SendData.php using php... please have a look at both codes and help me to create the code.... thank
------------ ReqData.html---------------
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>

 <script>

 var time = new Date();		
var curr_date = parseInt(time.getHours()+1);
var p = 13;
var g= 8;
var a ;
var A;
var K=0;
var s;
var inc;
alert('p'+p);
alert('g'+g);
 
 
 
 
function frmSubmit()
{
    var Message = '';
    // var alphaExp = /^[a-zA-Z0-9]+$/;
    if (document.frmForm.firstname.value=='') {
        Message = 'First name cannot be null\n';
        }
    else {
    if(!(document.frmForm.firstname.value.match(/^[a-zA-Z]+$/)))
        Message = 'First name can contain only letters, no numbers or special characters\n';
    }
    if (document.frmForm.lastname.value=='') {
        Message += 'Last name cannot be null\n';
        }
        else {
        if (!(document.frmForm.lastname.value.match(/^[a-zA-Z]+$/)))
            Message += 'Last name can contain only letters, no numbers or special characters\n';
        }
    if (document.frmForm.comment.value=='') {
        Message += 'Comment cannot be null\n';
        }

	if (Message != '')
    {
        alert(Message);
        return false;
    }
    return true;
}
 



 </script>
 <title> Dispute Encription</title>
    <head />
    <body onload="diffhellman();">

        <h2>
           Opening a Dispute
        </h2>
        <form name="frmForm" onsubmit="return frmSubmit()" action="SendData.php" method="post">
        First name:
        <input type="text" name="firstname" />
        <br />
        Last name:
        <input type="text" name="lastname" />
        <br />
        Please write your claim :<br />
        <textarea value="" id="comment" name="comment" onchange="" /></textarea>
                
        <br />
        
        <input type="hidden"  id="encrypted" name="encrypted" /></input>
        <br />
        <input type="submit" value="Submit" />
</form>
    </body>
</html>

---------------- SendData.php----------------
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>



<?php


?>


 <title> Dispute Decription</title>
    <head />
    <body>
        <h2>
            Showing Dispute Encription and Decription
        </h2>
        <form name="frmForm" action="RecCode.php" method="post">
        <br />
        Encrypted value :<br />
        <textarea id="encrypted" name="encrypted" /><?php  ?> </textarea>
		<br />
		Decrypted value :<br />
        <textarea id="decrypted" name="decrypted" /><?php ?> </textarea>
		

        </form>
    </body>
</html>

Open in new window

AussieSilverAsked:
Who is Participating?
 
StealthyDevConnect With a Mentor Commented:
Hi, please look at the below links and use your own technique.

http://www.adamsinfo.com/diffie-hellman-key-exchange/

http://www.example-code.com/php/dh_key_exchange.asp

Regards.

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.