Reliable Answers - News and Commentary

JavaScript Decryption Tool

The HTML Decoder

This is just a quick sample of how to accomplish embedded HTML entity decryption with javascript. It's actually only a small portion of the code at the Scumple I wrote several years ago, but it was necessary for another project I am working on, so I dedicated this page to demontrating that functionality.

Back to the point. The code here converts entity encoded values like &0032; to their actual text counterparts, and place results into the box below. To start, just paste or enter some entity-encoded text within the box below. Then click Decode Text.





Results will appear here.

The Code

<script type="text/javascript">
function decodetest(){
//get the input
  var t = document.getElementById('dectest').value;
//remove carriage returns
  t = t.replace(new RegExp("\\=\r\n","gim"), "");
//replace urlencoded values
  t = unescape(t);
//replacement values
  var thechrs = new Array(
    ' ','!','"','#','$','%','&',"'",'(',')','*','+',',','-','.','/','0','1','2','3',
    '4','5','6','7','8','9',':',';','<','=','>','?','@','A','B','C','D','E','F','G', 
    'H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','[', 
    '\\',']','^','_','`','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o',
    'p','q','r','s','t','u','v','w','x','y','z','{','|','}','~',' ','c','u','e','a',
    'a','a','a','c','e','e','e','i','i','i','a','a','e','ae','ae','o','o','o','u','u',
    'y','u','u','o','l','0','x','f','a','i','o','u','n','n','*','O','?','r','_','?',
    '?','!','<','>','_','_','_','|','|','a','a','a','c','|','|','+','+','c','y','+',
    '+','-','-','+','-','+','a','a','+','+','-','-','|','-','+','.','.','d','e','e',
    'e','i','i','i','i','+','+','_','_','|','i','_','o','o','o','o','o','o','u','p',
    'p','u','u','u','y','y','_',"'",'-','?','_','?','?','S','÷','¸','°','¨','·','¹',
    '³','²','_',' ');
//replace js numeric array values
  var l = 32;
  for (l = 32; l < 256; l++){
    t = t.replace(new RegExp("\\[" + l + ",","gim"),"[" + thechrs[l-32] + ",");
    t = t.replace(new RegExp("\\[" + l + ",","gim"),"[" + thechrs[l-32] + ",");
  }
  for (l = 32; l < 256; l++){
    t = t.replace(new RegExp("," + l + "\\]","gim"),"," + thechrs[l-32] + "]");
    t = t.replace(new RegExp("," + l + "\\]","gim"),"," + thechrs[l-32] + "]");
  }
  for (l = 32; l < 256; l++){
    t = t.replace(new RegExp("," + l + ",","gim"),"," + thechrs[l-32] + ",");
    t = t.replace(new RegExp("," + l + ",","gim"),"," + thechrs[l-32] + ",");
  }
  ta = t;
  t = t.replace(new RegExp("(\\[[^\\]]+)\\,([^\\]]+\\])","gim"), "$1$2");
  while(ta !== t){
    ta = t;
    t = t.replace(new RegExp("(\\[[^\\]]+)\\,([^\\]]+\\])","gim"), "$1$2");
  }
//replace entities
  var l = 32;
  for (l = 32; l < 100; l++){
    t = t.replace(new RegExp("&#" + l + ";","gim"),thechrs[l-32]);
    t = t.replace(new RegExp("&#0" + l + ";","gim"),thechrs[l-32]);
    t = t.replace(new RegExp("&#00" + l + ";","gim"),thechrs[l-32]);
  }
  var l = 100;
  for (l = 100; l < 256; l++){
    t = t.replace(new RegExp("&#" + l + ";","gim"),thechrs[l-32]);
    t = t.replace(new RegExp("&#0" + l + ";","gim"),thechrs[l-32]);
  }
//return results
  document.getElementById("parsed").innerHTML = t;
}
</script>
Carschooling by Diane Flynn Keith
Carschooling

Take me to the top

We invite you
to visit:

Professional Web Hosting and Design Services: 12 Point Design Local Homeschool provides the most up-to-date support group listings in a geographical and searchable index Budget Homeschool Kidjacked -- To seize control of a child, by use of force SaferPC dispels security misunderstandings and provides you with a solid understanding of viruses and computer security Reliable Answers - developer information, current news, human interest and legislative news Twain Harte Times - Twain Harte, CA - The closest you can get to Heaven on Earth Cranial Laser & Neurolymphatic Release Techniques (CLNRT) - Experience dramatic pain reduction At Summit Chiropractic our mission is to improve your quality of life - We know that health is much more than just not feeling pain Visit UniveralPreschool.com to learn about your preschool options.
Reliable Answers.com/js/decrypt.asp
Google