
function enChar(ptxt,key)
{

  var etxt,ltxt,lkey,i,j,chcode,pchcode,code,checksum;
  
  mincode=32;
  maxcode=127;

  checksum=ptxt.length
  checksum=checksum % 100
  key=checksum+''+key

  etxt = '';
  ltxt = ptxt.length;
  lkey = key.length;
  
  

  for (i=0;i<ltxt;i++)
  {
    pchcode=ptxt.charCodeAt(i);
    j = i % lkey;
    chcode = key.charCodeAt(j);
    
    if ((mincode <= pchcode) && (pchcode <= maxcode)) 
    {
    
      code=pchcode + chcode;
      while (code>maxcode)
      {
        code=code-maxcode + mincode-1;
      };
    }
    else
      code=pchcode;
      
      
    //   code=ptxt.charCodeAt(i);
      //  code=pch.charCode;
         
        
   // etxt = etxt + code + '';
    etxt = etxt + String.fromCharCode(code);
  //  etxt = etxt + pch;

  }
  
  return etxt;
}

function runcc(sourcectrl,destctrl)
{

   var s = document.getElementById(sourcectrl);
   var d = document.getElementById(destctrl);

   d.value=enChar(s.value,'83uehfkwpirhfdme9493ewsdj');
 
  
  return true;
}

function runccself(txtctrl)
{
  return runcc(txtctrl,txtctrl);;
}
