// Quick! Hide the java!
// Speaking of Java, this particular script is (C) Copyright 2002 Jim Tucek
// If you wish to use my Email Encryption script, these comments must be left
// alone!  That is all.

// Visit www.jracademy.com/~jtucek/ for script information and a bit of help
// setting it up, or www.jracademy.com/~jtucek/email.html for contact
// information.

// A brief history of this script can be found (and it's rather entertaining)
// at www.jracademy.com/~jtucek/eencrypt.html

function goForth(c,n,d) {
   c += ' ';
   var length = c.length;
   var number = 0;
   var bar = 0;
   var answer = '';
   for(var i = 0; i < length; i++) {
      number = 0;
      bar = 0;
      while(c.charCodeAt(i) != 32) {
         number = number * 10;
         number = number + c.charCodeAt(i)-48;
         i++;
      }
      answer += String.fromCharCode(decrypt(number,n,d));
   }
   // Updated security feature
   parent.location = 'm'+'a'+'i'+'l'+'t'+'o'+':'+answer;
}

function showText(c,n,d) {
   c += ' ';
   var length = c.length;
   var number = 0;
   var bar = 0;
   var answer = '';
   for(var i = 0; i < length; i++) {
      number = 0;
      bar = 0;
      while(c.charCodeAt(i) != 32) {
         number = number * 10;
         number = number + c.charCodeAt(i)-48;
         i++;
      }
      document.write('&');
      document.write('#');
      document.write(decrypt(number,n,d));
      document.write(';');
   }
}

function decrypt(c,n,d) {
   // Split exponents up
   if (d % 2== 0) {
      bar = 1;
      for(var i = 1; i <= d/2; i++) {
         foo = (c*c) % n;
         bar = (foo*bar) % n;
      }
   } else {
      bar = c;
      for(var i = 1; i <= d/2; i++) {
         foo = (c*c) % n;
         bar = (foo*bar) % n;
      }
   }
   return bar;
}
