Forums: Javascript Encoding Challenge - Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Javascript Encoding Challenge

#1 User is offline   extreme 

  • Specialist
  • Icon
  • Group: Specialist
  • Posts: 582
  • Joined: 02-September 03

Posted 15 March 2005 - 11:35 PM

If someone has extra time, I would like to know how to acomplish this:
This is how decrypt() function will look like for character "a"...

Quote

eval(

var options='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';

function decrypt(str) {
str=str.split('@').join('CAg');
str=str.split('!').join('W5');
str=str.split('*').join('CAgI');
var temp, result = '';
for(i=0; i<str.length; i += 4) {
temp = (options.indexOf(str.charAt(i)) & 0xff) <<18 | (options.indexOf(str.charAt(i +1)) & 0xff) <<12 | (options.indexOf(str.charAt(i +2)) & 0xff) << 6 | options.indexOf(str.charAt(i +3)) & 0xff;
result += String.fromCharCode((temp & 0xff0000) >>16, (temp & 0xff00) >>8, temp & 0xff);
}

if(str.charCodeAt(i -2) == 61) {
return(result.substring(0, result.length -2));
}
else if(str.charCodeAt(i -1) == 61) {
return(result.substring(0, result.length -1));
}
else {
return(result)
};

}

);

document.write(decrypt('YTxzY3JpcHQgbGFuZ3VhZ2U9SmF2YVNjcmlwdD52YXIgbWVzc2FnZT0iVGhpcyBjb2RlIGlzIHBy
b3RlY3RlZCEiOyBmd!jdGlvbiBjbGlja0lFNCgpeyBpZiAoZXZlbnQuYnV0dG9uPT0yKXsgYWxlcnQobWVzc2FnZSk7IHJ
ldHVybiBmYWxzZTsgfSB9IGZ1bmN0aW9uIGNsaWNrTlM0KGUpeyBpZiAoZG9jdW1lbnQubGF5ZXJzfHx
k
b2N1bWVudC5nZXRFbGVtZ!0QnlJZCYmIWRvY3VtZ!0LmFsbCl7IGlmIChlLndoaWNoPT0yfHxlLndoaWNoPT0zKXsgYWxlcnQobWVzc2FnZSk7IHJldHV
ybiBmYWxzZTsgfSB9IH0gaWYgKGRvY3VtZ!0LmxheWVycyl7IGRvY3VtZ!0LmNhcHR1cmVFdmVudHMoRXZlbnQuTU9VU0VET1dOKTsgZG9jdW1lbnQub25tb3VzZWRvd249Y2x
pY2tOUzQ7IH0gZWxzZSBpZiAoZG9jdW1lbnQuYWxsJiYhZG9jdW1lbnQuZ2V0RWxlbWVudEJ5SWQpeyB
k
b2N1bWVudC5vbm1vdXNlZG93bj1jbGlja0lFNDsgfSBkb2N1bWVudC5vbmNvbnRleHRtZ!1P!ldyBGd!jdGlvbigiYWxlcnQobWVzc2FnZSk7cmV0dXJuIGZhbHNlIikgPC9zY3JpcHQ+'));


I am interested in how the encrypt(str){} function would look like?
WUTranslink
0

#2 User is offline   satknis 

  • Corporal
  • Icon
  • Group: Members
  • Posts: 162
  • Joined: 18-March 04

Posted 17 March 2005 - 06:06 AM

you have to reverse the process wich decrypt does.
0

#3 User is offline   extreme 

  • Specialist
  • Icon
  • Group: Specialist
  • Posts: 582
  • Joined: 02-September 03

Posted 17 March 2005 - 06:58 PM

Think so?
:)
WUTranslink
0

#4 User is offline   ssss 

  • Private First Class
  • Icon
  • Group: Members
  • Posts: 71
  • Joined: 09-November 04

Posted 20 March 2005 - 09:30 PM

:D I think code is incomplete. as it shows lot of errors while i was tryin to dycrypt OR may be the way i am doing is wrong..but may be i am right. Anyway you can let me know full html page if you have found code in that or the way you ot in yr hand. ;)
0

#5 User is offline   extreme 

  • Specialist
  • Icon
  • Group: Specialist
  • Posts: 582
  • Joined: 02-September 03

Posted 21 March 2005 - 05:20 AM

Here you go.. This is as you see only letter "a" encrypted..

Attached File(s)

  • Attached File  1.html (2.47K)
    Number of downloads: 36

WUTranslink
0

#6 User is offline   ssss 

  • Private First Class
  • Icon
  • Group: Members
  • Posts: 71
  • Joined: 09-November 04

Posted 21 March 2005 - 10:03 PM

extreme, on Mar 21 2005, 01:20 PM, said:

Here you go.. This is as you see only letter "a" encrypted..


:rolleyes: :D Here is your dycrypted page


<html><body>
<!------------------------------------------------------------------

The HTML contents of this page are protected

-------------------------------------------------------------------->

<body>a<script language="Javascript">var message="This code is protected!"; function clickIE4(){ if (event.button==2){ alert(message); return false; } } function clickNS4(e){ if (document.layers||document.getElementById&&!document.all){ if (e.which==2||e.which==3){ alert(message); return false; } } } if (document.layers){ document.captureEvents(Event.MOUSEDOWN); document.onmousedown=clickNS4; } else if (document.all&&!document.getElementById){ document.onmousedown=clickIE4; } document.oncontextmenu=new Function("alert(message);return false") </script>
</body></html> ;)
0

#7 User is offline   extreme 

  • Specialist
  • Icon
  • Group: Specialist
  • Posts: 582
  • Joined: 02-September 03

Posted 22 March 2005 - 12:20 PM

yes, but I was interested in how the encrypt(){ } function would look like, so I can use it my programs as well..
WUTranslink
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users

  • Share



Our Sponsors:


SwiftLayer Affiliate Web Hosting