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!
Printable View
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!
This site will help you with that.
http://php.weblogs.com/php_jscript_vbscript_1
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
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.
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...."
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.
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......
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..
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;
}
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?
:-)
exactly c = c - will do the decrypt ..
Anytime you need any other help just let me know.. my email is [email protected]
^_-
Thanks again Cander !