
/**********************************|***********************************
'                  Homework Trader - College Papers Site
'                             Copyright 2009
'                           All Rights Reserved
'                         Web Solutions Division of
'                            JRA Systems, L.L.C.
'
' Application: Homework Trader - College Papers Site
' Module Type: Javascript
' Module Name: Encrypt_Decrypt.js
'
' General ecryption / decryption functions.
'
'*********************************************************************/

/**********************************|***********************************
' Module static data.
'*********************************************************************/

/**********************************************************************
' Encrypt string using key.
'
' function
' Encrypt
' (
'  strString_To_Encrypt
'  intKey
' )
'
'*********************************************************************/

function
Encrypt(strString_To_Encrypt, intKey)
{
  var to_enc = strString_To_Encrypt;
  
  var xor_key = intKey;
  var the_res = "";

  for(intIndex = 0; intIndex < to_enc.length; ++intIndex)
  {
    the_res += String.fromCharCode(xor_key ^ to_enc.charCodeAt(intIndex));
  }

  return the_res;
}

/**********************************************************************
' Decrypt string using key.
'
' function
' Decrypt
' (
'  strString_To_Decrypt
'  intKey
' )
'
'*********************************************************************/

function 
Decrypt(strString_To_Decrypt, intKey)
{
  var to_dec  = strString_To_Decrypt;
  var the_res = "";
  
  var xor_key = intKey;

  for(intIndex = 0; intIndex < to_dec.length; intIndex++)
  {
    the_res += String.fromCharCode(xor_key ^ to_dec.charCodeAt(intIndex));
  }

  return the_res;
}

