title: Handling large strings in Javascript
body: <p>I've made a function in Javascript to encrypt/encode a string before passing it to another page.</p>
  
  <p>The problem is that it isn't able to handle (editing, passing, returning etc...) large strings. Is there a way to do this in Javascript?</p>
  
  <p><strong>Note:</strong> At the moment I do not use jQuery because I think it's too complicated.</p>
  
  <p>Here's some example code:</p>
  
  <pre><code>    function replaceAt(str, index, character) {
          return str.substr(0, index) + character + str.substr(index+character.length);
      }
  
      function EncryptURL(inputstring) {
          var output = inputstring;
          for(var i=0; i&lt;output.length; i++) {
              output = replaceAt(output, i, String.fromCharCode(output.charCodeAt(i) + 5));
          }
          return output;
      }
  </code></pre>
  
  <p>The function simply shifts each character 5 characters to the right. Ex: A -> F</p>
  
  <p><strong>Example input:</strong> <code>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA</code></p>
  
  <p><strong>Output:</strong> <code>FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFKKKKKKKKKKKKKKKKKKK</code></p>
  
  <p>When inputting a large string the characters are getting messed up somewhere around index 58. No errors.</p>
  
  <p>EDIT:</p>
  
  <p>The page language is HTML by the way.</p>
  
  <p><strong><em>More code:</em></strong></p>
  
  <pre><code>    function DoubleEncryptURLToURLBox() {
          var namesarraystr = document.varreciever.variab.value; //Names separated by '_'. Example: Vincent_Jack_Felix_Simon_Jonathan_Monica_Eva_Tony_Anna
          var output = ""; output = namesarraystr;
          var i = 0;
  
          if(output.indexOf("?") != -1) {
              i = output.indexOf("?") + 1;
              output = output.substring(output.indexOf("?"));
  
              for(i = i; i&lt;output.length; i++) {
                  output = replaceAt(output, i, String.fromCharCode(output.charCodeAt(i) + 5));
              }
              output = "http://www.[website].com/redirect.html?" + EncryptURL(("nrc" + output)); //+ EncryptURL("?true");
          }
  
          document.getElementById("SettingsDiv").style.height = "auto";
          document.getElementById("CopyURLBox").style.visibility = "visible";
          document.getElementById("CopyURLBox").value = output;
      }
  </code></pre>
  
  <p>Sorry about it being long.</p>