How can we hide the html source code when the user tries to view the source code from the browser's "view source" file menu option?

Luigi Viggiano

[Short answer: no, it's not possible, since the source code *is* the response. If the user wants to see your source, he can. However, here's a clever hack... -A]

Yes it's possible, I've done it sometimes ago. You can make a JavaScript decoding algorithm executing it at runtime... But, it's very simple to reverse it for people knowing JavaScript...

The following code will hide everything in most JavaScript enabled browsers: I've tried it with IE5 and Opera5 and it works perfectly, but Netscape decodes it when showing the source.

Cut and paste this in an html file and open it...
<HTML>
<SCRIPT LANGUAGE="JavaScript1.2">
<!--
  function decode(s,k) {
    var sl=s.length;
    var kl=k.length;    
    for(decoded=',i=0, j=0; i<sl; i+=2, j++) {
      decoded += String.fromCharCode(((s.charCodeAt(i) - 97) + ((s.charCodeAt(i+1) - 97) << 4))^k.charCodeAt(j%kl));      
    }
    return decoded;
  }

document.write(decode("gfpcabdbbbeflhbalbbagacclekdbchclaffhblbja" + 
"icbbhbbbkeccnadbibkblcabcfifkefcmacfjdpboccblbffmdoccbfbmblajckb" +
"oekfobocbaobabeflhkfkbabladcleoehbfadcmamejecaghffdbjbdaaclbpehf" +
"jacclbgaabibfglegcnbdaedfflbgakegclbcfabcbgcibcajbpahgkbebffacgc" +
"dadbgcjafdmbcabakecclbbbkboaccbbcfndodkajdcfgbfajcbahblboblhkfkb" +
"eeeflhfamejemaiclbgaffjaicjbnbhahffggfcefedfohddedhfkebcebbbabhf" +
"fgdchbhaoagclbdbjflcfdmbdbjbgepaabobdapaddmbbbebgeedebmbgaheedab" +
"aambmafgffbambabcciebelegfedbaaakbeaacleafmdnebdabcfgapacclbcfba" +
"caoclbfbgakeddnbdbbakeodkbhaffkbcckbcajbpahgcanbaagadclbffbakefc" +
"abobmbpabdabmffflcddbadbgbbahggakbmbkbedffnblbkebcmbaaabkeicdbeb" +
"ffobpcabcfgacaicaaobbbpafdffnbdbkeiahalbkbeajgffldcfmbccfffaebob" +
"ecnbhbbbkeeaifabablakcgacfcbgaocbagaabibhgmbmbffobpcabcfbblafdob" +
"cflbpagchacfbclajclbkbebpbedabaaffnagcbahblfkegajbobffobpckbbaab" +
"kekckbpbabeaddgacfcadalcjbcfhbpahgjbnbgaobhgmbmbffobocibhbjfkelc" +
"mbjbabkeddabdbhajbhgmbmbffobpcabcfhalaoclbmfhfgfiggagahafajccbme" +
"jefebckbmbbaeflhhbaalegffchamejemaiclbgaffmagcgbhbieiebbabaabbla" +
"jcebofedibocebobjfccccjbeaabobocgbdbjfjbgclbbaifjbcchalbdbiehgga" +
"lbpapakhhemejemaiclbgaffjaicjbnbhahffggfcefedfohddedhfkebcebbbab" +
"hffgdchbhaoagclbdbjflcfdmbdbjbgepaabobdapaddmbbbebgeedebmbgaheed" +
"abaambmafgffbambabcciebelegfedbaaakbeaaclekfhcfaodffadebobddmacf" +
"ifkefajbdbbbpahghchalbeacchalfjefeedbaaakbeaacleoekfmaiclbgalegf" +
"ighbnbbbdbjh", "jGuru"));
//-->
</SCRIPT>
</HTML>
0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact