Results 1 to 12 of 12

Thread: convert VBScript to JavaScript

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Location
    Connecticut
    Posts
    98
    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!

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    This site will help you with that.

    http://php.weblogs.com/php_jscript_vbscript_1
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Location
    Connecticut
    Posts
    98

    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

  4. #4
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    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.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Location
    Connecticut
    Posts
    98

    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...."

  6. #6
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    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.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Location
    Connecticut
    Posts
    98

    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......

  8. #8
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    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..
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  9. #9
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    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;

    }
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Location
    Connecticut
    Posts
    98

    =)

    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?

    :-)

  11. #11
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    exactly c = c - will do the decrypt ..

    Anytime you need any other help just let me know.. my email is [email protected]

    ^_-
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  12. #12

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Location
    Connecticut
    Posts
    98

    =)

    Thanks again Cander !

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width