JAVA的Cipher.DECRYPT_MODE
和.NET的3desProvider.Mode = CipherMode.ECB
是对应的。

import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;

import org.apache.commons.codec.binary.Base64;

public class CryptUtil3DES {
    
private static final String CRYPT_KEY = "v3VC7LfCq6IL5KgIglqZrQ1b";
    
private static final String CRYPT_ALGORITHM = "DESede";
    
    
public static String decrypt(String value) {
        
try {
            SecretKeySpec keySpec 
= new SecretKeySpec(CRYPT_KEY.getBytes(), CRYPT_ALGORITHM);
            Cipher cipher 
= Cipher.getInstance(CRYPT_ALGORITHM);
            cipher.init(Cipher.DECRYPT_MODE, keySpec);
            
            
byte[] decodedByte = Base64.decodeBase64(value.getBytes());
            
byte[] decryptedByte = cipher.doFinal(decodedByte);            
            
return new String(decryptedByte);
        }
 catch(Exception e) {
            
return null;
        }

    }

    
    
public static String encrypt(String value) {
        
try {
            SecretKeySpec keySpec 
= new SecretKeySpec(CRYPT_KEY.getBytes(), CRYPT_ALGORITHM);
            Cipher cipher 
= Cipher.getInstance(CRYPT_ALGORITHM);
            cipher.init(Cipher.ENCRYPT_MODE, keySpec);
            
            
byte[] encryptedByte = cipher.doFinal(value.getBytes());
            
byte[] encodedByte = Base64.encodeBase64(encryptedByte);
            
return new String(encodedByte);
        }
 catch(Exception e) {
            
return null;
        }

    }

}


2。C#
public class CryptionData
{
    
// The length of Encryptionstring should be 24 byte and not be a weak key
    private string EncryptionString;

    
// The length of initialization vector should be 8 byte
    private static Byte[] EncryptionIV = Encoding.Default.GetBytes("        ");

    
/// <summary>
    /// Constructor
    /// </summary>
    public CryptionData()
    
{
        
    }


    
/// <summary>
    /// Constructor
    /// </summary>
    /// <param name="EncryptionString">SecureKey</param>
    public CryptionData(string EncryptionString)
    
{
        
this.EncryptionString = EncryptionString;
    }


    
/// <summary>
    /// Encryption method for byte array
    /// </summary>
    /// <param name="SourceData">source data</param>
    /// <returns>byte array</returns>
    public byte[] EncryptionByteData(byte[] SourceData)
    
{
        
byte[] returnData = null;
        
try
        
{
            
// Create TripleDESCryptoServiceProvider object
            TripleDESCryptoServiceProvider desProvider = new TripleDESCryptoServiceProvider();

            
// Set SecureKey and IV of desProvider
            byte[] byteKey = Encoding.Default.GetBytes(EncryptionString);
            desProvider.Key 
= byteKey;
            desProvider.IV 
= EncryptionIV;
            desProvider.Mode 
= CipherMode.ECB;
 
            
// A MemoryStream object
            MemoryStream ms = new MemoryStream();

            
// Create Encryptor
            ICryptoTransform encrypto = desProvider.CreateEncryptor();

            
// Create CryptoStream object
            CryptoStream cs = new CryptoStream(ms, encrypto, CryptoStreamMode.Write);

            
// Encrypt SourceData
            cs.Write(SourceData, 0, SourceData.Length);
            cs.FlushFinalBlock();

            
// Get Encryption result
            returnData = ms.ToArray();
        }

        
catch (Exception ex)
        
{
            
throw ex;
        }


        
return returnData;

    }


    
/// <summary>
    /// Decryption method for byte array
    /// </summary>
    /// <param name="SourceData">source data</param>
    /// <returns>byte array</returns>
    public byte[] DecryptionByteData(byte[] SourceData)
    
{
        
byte[] returnData = null;
        
try
        
{
            
// Create TripleDESCryptoServiceProvider object
            TripleDESCryptoServiceProvider desProvider = new TripleDESCryptoServiceProvider();

            
// Set SecureKey and IV of desProvider
            byte[] byteKey = Encoding.Default.GetBytes(EncryptionString);
            desProvider.Key 
= byteKey;
            desProvider.IV 
= EncryptionIV;
            desProvider.Mode 
= CipherMode.ECB;
            
// A MemoryStream object
            MemoryStream ms = new MemoryStream();

            
// Create Decryptor
            ICryptoTransform encrypto = desProvider.CreateDecryptor();

            
// Create CryptoStream object
            CryptoStream cs = new CryptoStream(ms, encrypto, CryptoStreamMode.Write);

            
// Decrypt SourceData
            cs.Write(SourceData, 0, SourceData.Length);
            cs.FlushFinalBlock();

            
// Get Decryption result
            returnData = ms.ToArray();
        }

        
catch (Exception ex)
        
{
            
throw ex;
        }

        
return returnData;

    }


    
/// <summary>
    /// Encryption method for string
    /// </summary>
    /// <param name="SourceData">source data</param>
    /// <returns>string</returns>
    public string EncryptionStringData(string SourceData)
    
{
        
try
        
{
            
// Convert source data from string to byte array
            byte[] SourData = Encoding.Default.GetBytes(SourceData);

            
// Encrypt byte array
            byte[] retData = EncryptionByteData(SourData);

            
// Convert encryption result from byte array to Base64String
            return Convert.ToBase64String(retData, 0, retData.Length);
        }

        
catch (Exception ex)
        
{
            
throw ex;
        }

    }


    
/// <summary>
    /// Decryption method for string
    /// </summary>
    /// <param name="SourceData">source data</param>
    /// <returns>string</returns>
    public string DecryptionStringdata(string SourceData)
    
{
        
try
        
{
            
// Convert source data from Base64String to byte array
            byte[] SourData = Convert.FromBase64String(SourceData);

            
// Decrypt byte array
            byte[] retData = DecryptionByteData(SourData);

            
// Convert Decryption result from byte array to string
            return Encoding.Default.GetString(retData, 0, retData.Length);
        }

        
catch (Exception ex)
        
{
            
throw ex;
        }

    }

}
msdn 的例子中没有这句话。desProvider.Mode = CipherMode.ECB;
  如果没有的话,java的那段程序的加密结果。在下面的c#中不能正确解密。 反之亦然。
  以上是实际的调查结果。 具体3des的规范不是很了解。