I have two web site, one is based on Weblogic , Java web site, the
other is base MS IIS, asp web site.

there is a sensitive data from Java Web Site, enrypted by DES, then
send out the encrypted BASE64 Code text to the MS IIS,

asp web site receive the data , in BASE64 code, use the CAPICOM to
decrypt it, the do the other biz proccess.

In MS capicom , the CAPICOM_ENCRYPTION_ALGORITHM_DES , mode is unknown(it
is my #1 question) , padding is PKCS#7(I guess).

(I appreciate that someone tell me the exact "mode" and "padding" of CAPICOM_ENCRYPTION_ALGORITHM_DES
)

In Java , Cipher cipher = Cipher.getInstance("DES/CBC/PKCS7","Cryptix");

I have create these two version encrytion, but the output is totally
different,

Is there someone who can help me out?

tony.


Java :

import java.io.*;
import java.security.*;
//import javax.crypto.*;
import xjava.security.*;

//import javax.crypto.spec.*;

import sun.misc.*;
import cryptix.provider.key.RawSecretKey;

public class Encrypt
{
public static void main (String[] args) throws Exception
{

java.security.Security.addProvider(new cryptix.provider.Cryptix());

// Create a cipher

Cipher cipher = Cipher.getInstance("DES/CBC/PKCS7");

BASE64Decoder decoder = new BASE64Decoder();

RawSecretKey key = new RawSecretKey(
"DES",decoder.decodeBuffer("Gu8PDg7/PzY=") );

cipher.initEncrypt(key);

// collect input string
String input="PleaseEncryptMyString";
// convert the input the UTF8 format

byte[] inputBytes = input.getBytes("UTF8");

// Encode

byte[] outputBytes = cipher.doFinal(inputBytes);

// Print out the digest in base64.

BASE64Encoder encoder = new BASE64Encoder();
String base64 = encoder.encode(outputBytes);
System.out.println(base64.length());
System.out.println(base64);
}
}

The Output: is

32
HwzGnD6lE2zGm10KFcSRrumE6kOhnHMB


VB


Sub EncryptMessage(ByVal TobeEncrypted As String, ByVal hidden As String,
ByVal filename As String)

On Error GoTo ErrorHandler

' Declare and initialize an EncryptedData object.
' Algorithm.Name and KeyLength do not need to be set.

Dim message As New EncryptedData
message.Content = TobeEncrypted
message.SetSecret hidden
' Optionally, the encryption algorithm and key length can be set.
' If these properties are not set, the default algorithm and key
' length are used.
' Information about the algorithm and key length is saved with the
' encrypted string and the individual decrypting the message does not
' need to set these properties.

message.Algorithm.Name = CAPICOM_ENCRYPTION_ALGORITHM_DES

'Declare the string that will hold the encrypted message.

Dim encryptedmessage As String

'Encrypt the message storing the result in the encryptedmessage string
encryptedmessage = message.Encrypt

' Optionally, check the length of the encrypted string to make sure that
the
' encrypt method worked.

If Len(encryptedmessage) < 1 Then
MsgBox "no message encrypted. "
Else
MsgBox " Message is " & Len(encryptedmessage) & " characters"

' Open an output file and write the encrypted message to the file.
' The file is not opened if there is no message to write.
Open filename For Output As #1
Write #1, encryptedmessage
Close #1
MsgBox "Encrypted message written to file "
End If

' Release the EncryptedData object.
Set message = Nothing

Exit Sub

ErrorHandler:
If Err.Number > 0 Then
MsgBox "VB Error found:" & Err.Description
Else
MsgBox "CAPICOM error found : " & Err.Number
End If
End Sub

Private Sub Form_Load()
Call EncryptMessage("PleaseEncryptMyString", "Gu8PDg7/PzY=",
"c:\temp\showme.txt")
End Sub

The Output is

170
MHkGCSsGAQQBgjdYA6BsMGoGCisGAQQBgjdYAwGgXDBaAgMBAAACAmYBAgFABAg7
J+zB5J/2QQQQaQv86hIIKEW38j/mwrf0sQQwtJpXXGDYYplQEYN0NwjWPsGq2Ga9
ELklufSM/I5Ctcu5RNBxgRsdKeUh/afCixgd