zattz
asked on
javascript encryption
Hi,
I found the following function that decrypts something. I'm not sure how this works. Can somebody write a function that does the reverse. IE: one that encrypts
The decryption function is:
function hdecrypt(s){var o="",ar=new
Array(),os="",ic=0,p=0;
for(i=0;i<s.length;i++){c= s.charcode at(i);
if (c<128)c=c^((p++%8)+1);os+ =String.fr omCharCode (c);
if(os.length>80){ar[ic++]= os;os=""}} o=ar.join( "")+os;ret urn o}
I found the following function that decrypts something. I'm not sure how this works. Can somebody write a function that does the reverse. IE: one that encrypts
The decryption function is:
function hdecrypt(s){var o="",ar=new
Array(),os="",ic=0,p=0;
for(i=0;i<s.length;i++){c=
if (c<128)c=c^((p++%8)+1);os+
if(os.length>80){ar[ic++]=
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Did you try my solution..
_PA
_PA
ASKER
Sorry forgot about this
Thanks for the 'A', good luck, and Happy New Year.
ASKER
And to you :>
ASKER
I was surprised you thanked me for the 'A'. Usually I only get people complaining when I give a C! The other day somebody gave me a one line answer for a 500 point question and expected an A!
Well, I try to be polite, and find that it is a good habit to get into.
I guess this is not going to be possible. you can create a routine that encrypts and decrypts using Javascript, that bit is no problem. Where are you going to store your encryption key though? Javascript is not compiled and therefore anyone can see your code. You could then view the code find the key and crack the password very very easily.
But try these below options...
http://javascript.internet.com/passwords/ascii-encryption.html#source
XOR Encryption: Sample Code
<script>
str=''
str=str+String.fromCharCod
str=str+String.fromCharCod
str=str+String.fromCharCod
str=str+String.fromCharCod
str=str+String.fromCharCod
str=str+String.fromCharCod
alert(str)
</script>
http://guymal.com/mycode/xor_js_encryption/
More info. Use microsoft script encoder, it is free :
http://www.microsoft.com/downloads/details.aspx?FamilyId=E7877F67-C447-4873-B1B0-21F0626A6329&displaylang=en
FOR Netscape/Mozilla there is no encryption only scrambeling :
http://www.shopable.co.uk/scrambler.html
http://www.brainjar.com/js/crunch/
R.K