Running VBScript 32-bit or 64-bit

When running a VBScript, on a 64-bit Windows system it is possible to run either as a 32-bit process, or a 64-bit process. If running 32-bit, then you need the 32-bit ActiveX. If running 64-bit, then you need the 64-bit ActiveX.

To run a 32-bit VBScript on a 64-bit system, you do this:

REM This is the 32-bit cscript.
C:\windows\sysWOW64\cscript jsonTest.vbs

To run a 64-bit VBScript, you do this:

REM This is the 64-bit cscript.
C:\windows\system32\cscript jsonTest.vbs

or simply this:

cscript jsonTest.vbs

If you double-click on the .vbs to run it from Windows Explorer, then you’ll be running as a 64-bit process. The default, unless you took care to explicitly run as 32-bit by invoking the cscript.exe under sysWOW64, is that you’ll be running as a 64-bit process, and in that case you’ll need the 64-bit Chilkat ActiveX registered on your system.

Matching DES Encryption in Java and VBScript

This page shows both Java JCE DES encryption examples, as well as examples using the Chilkat Encryption component in both Java and VBScript. Each of these examples produces identical output:

The string: ABC123 encrypts to 6DA02B6AE1EA32D8 (as a hexidecimalized string)

Java bytes-to-hex Encoding Utility Function

 	public static String toHex (byte buf[]) {
      StringBuffer strbuf = new StringBuffer(buf.length * 2);
      int i;

      for (i = 0; i < buf.length; i++) {
       if (((int) buf[i] & 0xff) < 0x10)

       strbuf.append(Long.toString((int) buf[i] & 0xff, 16));

      return strbuf.toString();

56-bit DES Encryption Java JCE Example 1

        String password = "12345678";
        byte[] keyBytes = password.getBytes();
        SecretKeySpec skeySpec = new SecretKeySpec(keyBytes, "DES");
        Cipher cipher = Cipher.getInstance("DES");
        cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
        String original = "ABC123";
        byte[] inBytes = original.getBytes();
        byte[] encrypted = cipher.doFinal(inBytes);
        String dStr = decrypt("12345678",encrypted);

56-bit DES Encryption Java JCE Example 2

        DESKeySpec ks = new DESKeySpec( keyBytes );
        SecretKeyFactory kf = SecretKeyFactory.getInstance( "DES" );
        SecretKey ky = kf.generateSecret( ks );
        Cipher cf = Cipher.getInstance( "DES" );
        cf.init( Cipher.ENCRYPT_MODE, ky );
        byte[] encrypted2 = cipher.doFinal(inBytes);

56-bit DES Encryption Java w/ Chilkat

    CkCrypt2 crypt = new CkCrypt2();
    crypt.UnlockComponent("30-day Trial");
	CkByteData inData = new CkByteData();
	CkString encryptedStr = new CkString();

56-bit DES Encryption VBScript w/ Chilkat

set crypt = CreateObject("Chilkat.Crypt2")

crypt.UnlockComponent "30-day Trial"

crypt.CryptAlgorithm = "DES"
crypt.CipherMode = "ECB"
crypt.KeyLength = 64
crypt.EncodingMode = "hex"
crypt.SetEncodedKey "12345678","ascii"

MsgBox crypt.EncryptStringENC("ABC123")

56-bit DES Decryption in Java JCE

    public static String decrypt(String password, byte[] encodedData)
      throws Exception

        byte[] originalData = null;

        SecretKeySpec key = new SecretKeySpec(password.getBytes (), "DES");
        Cipher cipher = Cipher.getInstance("DES");
        cipher.init(Cipher.DECRYPT_MODE, key);
        originalData = cipher.doFinal(encodedData);

        String s = new String(originalData);
        return s;