|
-
Mar 8th, 2001, 07:27 AM
#1
Thread Starter
Lively Member
I have a need to convert a piece of VBScript over to JavaScript.
Does anyone know of any utilities or sites that help with this conversion? I'm guessing no, but I figured I'd ask before I start reworking it.
Thanks!
-
Mar 8th, 2001, 11:37 AM
#2
-
Mar 8th, 2001, 01:50 PM
#3
Thread Starter
Lively Member
anyone ?
Anyone want to take a stab at converting this VBScript encryption routine over to JavaScript?
I have no idea where to begin!
Code:
Function Encrypt(strText, strPwd)
Dim strBuff, i, c
on error resume next
strBuff = ""
For i = 1 To Len(strText)
c = Asc(Mid(strText, i, 1))
c = c + Asc(Mid(strPwd, (i Mod Len(strPwd)) + 1, 1))
strBuff = strBuff & Chr(c And &HFF)
Next
Encrypt = strBuff
End Function
-
Mar 8th, 2001, 03:30 PM
#4
umm I have to ask. If you need javascript to make it cross browser then that makes that routine kind of silly. think about this, if you need to encrypt information, then you have the encrytpion code right there client side for them to view. Therefore you just showed a potential hacker all they need to de crypt something.
-
Mar 9th, 2001, 08:33 AM
#5
Thread Starter
Lively Member
yep
I agree, but its not my project.
I explained that to the project "owner" and it seems that the data that is being stored in the cookie, encrypted, is not all that sensitive anyway.
It's just a marketing thing....."Our app encrypts all stored info, bla, bla, bla...."
-
Mar 9th, 2001, 09:31 AM
#6
Ok ..well Ill give it a shot and changing over the code to javascript for you. Ill post it here if I can figure it out.
-
Mar 9th, 2001, 09:46 AM
#7
Thread Starter
Lively Member
THANKS!
THANKS Cander!
Actually, it doesn't have to be an exact conversion. Something close is fine.
I will also need to reverse the code to do decryption, but thats no big deal.
Thanks again. I am just learning JavaScript so this one is a little out of my realm......
-
Mar 9th, 2001, 10:00 AM
#8
well im close to figuring it out now. I have the conversion for ASC, CHR, and MOD, now im just working on fining out the covnverison for mid and len. Just for your reference here are the javascrtipt versions I know so far....
ASC = a string value.charCodeAt(0) for example "A".charCodeAt(0) will give you 65
CHR = String.fromCharCode(code) for example String.fromCharCode(65) will give you "A"
MOD = %
Just for your future reference...
I will keep working on it..
-
Mar 9th, 2001, 11:41 AM
#9
yaahh I figured it out..
function Encrypt(strText, strPwd)
{
var strBuff=new String("");
for (var i=0; i<strText.length; i++)
{
c = (strText.substring(i,i+1)).charCodeAt(0);
c = c + (strPwd.substring((i % strPwd.length),i+1)).charCodeAt(0);
strBuff = strBuff + String.fromCharCode(c);
}
return strBuff;
}
-
Mar 9th, 2001, 12:17 PM
#10
Thread Starter
Lively Member
=)
Dude, you rule!!
Thanks very much, I appreciate it a LOT !
And to make it a DE-crypt function I just change
c = c + .....
to
c = c - ....
Right?
:-)
-
Mar 9th, 2001, 12:18 PM
#11
exactly c = c - will do the decrypt ..
Anytime you need any other help just let me know.. my email is [email protected]
^_-
-
Mar 9th, 2001, 12:27 PM
#12
Thread Starter
Lively Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|