Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 error detection javascript/html
Index -> Graphics and Design, Web Design -> (X)HTML Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
guttface




PostPosted: Mon Apr 04, 2005 6:52 pm   Post subject: error detection javascript/html

this is a javascript question but i didnt no where else to put it. i keep getting an error that a function is expected on line 72. i've spent 4 hours on it and cant find an answer. plz help.
code:
<html>
<head>
<script laguage="JavaScript">

function PRIME(max,p1){
        while(true){
                var prime = Math.floor(Math.random() * max) ;
                var factor=2;
               while (factor < prime && (prime%factor)!=0){
                        factor++;                   
                 if (factor==prime && factor!=p1 ) return prime;
                }
        }
}

function GCD(a,b){
        while(c != 0){
                var c = a % b;
                a = b;
                b = c;
        }
        return a;
}

function E(phi){
        var e=3;
        while(GCD(phi,e)!=1){
           e+=2;
        }
        return e;
}

function D(S,L) {
a = new Array();
q = new Array();
x = new Array();

   a[0]=L; a[1]=S; i=0;
   while(a[i]%a[i+1]!=0)
     {
       a[i+2]=a[i]%a[i+1];
       q[i+1]=Math.floor(a[i]/a[i+1]);
       i++;
     }
   var n=i+1; x[n]=0; x[n-1]=1;
   for(j=n-2;j>=0;j--)  x[j] = x[j+1] * q[j+1] + x[j+2];
   if (a[n] != 1) return "No Inverse";
   if((x[1]*a[0])>(x[0]*a[1])) return L - x[0];
   else return x[0];
}

function NUMLET(str){
        var numstr="";
        for(i=0;i<str.length;i++){
                numstr+=(str.charCodeAt(i)-96) + " ";
        }
        return numstr;
}

function EXP(a,b){
        var t=1;
        for(i=1;i<=b;i++){
           t=t*a;
        }
        return t;
}

function ENCIPHER(str){
        var numstr=str.split(" ");
        var ciphernum="";
        for(i=0;i<numstr.length;i++){
                ciphernum+=(EXP(parseInt(numstr(i)),parseInt(e.value))%parseInt(n.value)) + " ";
        }
        return ciphernum;
}

</script>
</head>
<body>
<input type="text" name="prime1">
<input type="button" value="Generate Prime 1" onClick="prime1.value=PRIME(30,parseInt(prime2.value));"><br>
<input type="text" name="prime2">
<input type="button" value="Generate Prime 2" onClick="prime2.value=PRIME(30,parseInt(prime1.value));"><br>
<input type="text" name="n">
<input type="button" value="Generate n" onClick="n.value=(parseInt(prime1.value))*(parseInt(prime2.value));"><br>
<input type="text" name="phi">
<input type="button" value="Generate phi" onClick="phi.value=(parseInt(prime1.value)-1)*(parseInt(prime2.value)-1);"><br>
<input type="text" name="e">
<input type="button" value="Generate e" onClick="e.value=E(parseInt(phi.value));"><br>
<input type="text" name="d">
<input type="button" value="Generate d" onClick="d.value=D(parseInt(e.value),parseInt(phi.value));"><br><br>

<input type="text" name="ml">
<input type="button" value="Generate Ciphertext" onClick="mn.value=NUMLET(ml.value);cn.value=ENCIPHER(mn.value);"><br>
<input type="text" name="mn"><br>
<input type="text" name="cn">
<input type="button" value="Generate Plaintext" onClick="mn2.value='1234';mn2.value+=' 5678';"><br>
<input type="text" name="mn2"><br>
<input type="text" name="ml2">
</body>
</html>
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Graphics and Design, Web Design -> (X)HTML Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 1 Posts ]
Jump to:   


Style:  
Search: