这是我的.net代码
byte[] byKey = System.Text.ASCIIEncoding.ASCII.GetBytes("12345678");
byte[] byIV = System.Text.ASCIIEncoding.ASCII.GetBytes("12345678");
DESCryptoServiceProvider cryptoProvider = new DESCryptoServiceProvider();
// int i = cryptoProvider.KeySize;
MemoryStream ms = new MemoryStream();
CryptoStream cst = new CryptoStream(ms, cryptoProvider.CreateEncryptor(byKey, byIV), CryptoStreamMode.Write);
StreamWriter sw = new StreamWriter(cst);
sw.Write(data);
sw.Flush();
cst.FlushFinalBlock();
sw.Flush();
return Convert.ToBase64String(ms.GetBuffer(), 0, (int)ms.Length);
这是我的java代码
`
String epsKey ="12345678";
String str ="hcs";
DESKeySpec desKeySpec = new DESKeySpec(epsKey.getBytes());
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
SecretKey key = keyFactory.generateSecret(desKeySpec);
Cipher ecipher = Cipher.getInstance("DES");
//ecipher = Cipher.getInstance("DES/CBC/PKCS5Padding");
ecipher.init(Cipher.ENCRYPT_MODE, key);
byte[] enc = ecipher.doFinal(str.getBytes("UTF8"));
String encryptedString = new BASE64Encoder().encode(enc);
System.out.println(encryptedString);
`