Reply
Encoder Edit
Old 07-05-2005, 11:11 PM Encoder Edit
stickycarrots's Avatar
Experienced Talker

Posts: 35
Location: stickycarrots.com
I want this encoder script to split up the characters so it's not one big long strand of code. It doesn't matter really how it splits it up.

I know there has to be a way to edit the code so it'll split it up and I've been trying to figure it out, but I just can't.

Your help is great appreciated.

Here's the script that needs edited:
Code:
<script language="JavaScript">

//Message Encrypter- By Naresh Hotchandani (nhotchandani@rediffmail.com)
//Script featured on Dynamic Drive
//Visit http://www.dynamicdrive.com for this script and more 

len=0;

function CalcKey()
{
len=0;
var temp=document.Encrypt.Key.value;

for(i=0;i<temp.length;i++)
{
len=len+temp.charCodeAt(i);
}
if(len==0)
{
alert('Please Enter the appropriate Key');
document.Encrypt.Key.focus();
}
return len;
}


function Encryption()
{

CalcKey();
document.Encrypt.Encrypted.value="";
var txt=document.Encrypt.normal.value;

var net="";
var fin=0;

if(len>0)
{

if(txt.length>0)
{
for(i=0;i<txt.length;i++)
{
fin=txt.charCodeAt(i)+len;

if(fin>99)
{
net=net+fin;
}
else
{
net=net+'0'+fin;
}
}

document.Encrypt.Encrypted.value=net;
document.Encrypt.normal.value="";
}
else
{
alert('Please Enter the Text to be Encrypted');
document.Encrypt.normal.focus();
}

}
}

function Decryption()
{
var txt=document.Encrypt.Encrypted.value;
var j=3;
var temp1;
var res="";

CalcKey();

if(len>0)
{
if(txt.length>0)
{
for(i=0;i<txt.length;i+=3)
{

var temp=txt.substring(i,j);
temp1=(parseInt(temp)-len);
var t=unescape('%'+temp1.toString(16));
if(t=='%d' || t=='%a')
{
res=res+' ';
}
else
{
res=res+t
} 
j+=3;
}
document.Encrypt.normal.value=res;
document.Encrypt.Encrypted.value="";
}
else
{
alert('Please Enter the Encrypted Text');
document.Encrypt.Encrypted.focus();
}
}
}

</script>
Thanks again,
stickycarrots

Last edited by stickycarrots : 07-05-2005 at 11:15 PM.
stickycarrots is offline
Reply With Quote
View Public Profile Visit stickycarrots's homepage!
 
When You Register, These Ads Go Away!
Old 07-06-2005, 04:35 AM
chrishirst's Avatar
Super Moderator

Latest Blog Post:
Javascript alert
Posts: 13,690
Location: Blackpool. UK
use a loop and the string.slice method to split it up.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 07-06-2005, 12:32 PM
stickycarrots's Avatar
Experienced Talker

Posts: 35
Location: stickycarrots.com
How do you apply that to the script so that it works?
stickycarrots is offline
Reply With Quote
View Public Profile Visit stickycarrots's homepage!
 
Reply     « Reply to Encoder Edit
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.12656 seconds with 12 queries