以上是java的一个加密解密算法,现在要根据这个算法编写C#算法,请各位高手给出代码。多谢。分不够可以加,在线等。

gralei 2011-12-27 05:11:05
public class DES
{
private byte[] EncodAndDecodeKey = null;

private static String strAlgorithm = "DESede";

public void initPhar()
{
String strKey = "1234567890987650abcdefgh";
int size = strKey.length();
byte[] temKey = strKey.getBytes();
byte[] EncodAndDecodeKey = new byte[size];
for (int i = 0; i < size; i++) {
EncodAndDecodeKey[i] = temKey[i];
}
}
public void DecryptData(String strEnDataFile, String strDeDataFile)
{
try
{
SecretKeySpec destmp = new SecretKeySpec(this.EncodAndDecodeKey, "DESede");
SecretKey theKey = destmp;

Cipher cipher = Cipher.getInstance("DESede");

cipher.init(2, theKey);
FileInputStream in = new FileInputStream(strEnDataFile);
FileOutputStream out = new FileOutputStream(strDeDataFile);
int len;
while ((len = in.read()) > 0) {
byte[] Data = new byte[len];
in.read(Data);
byte[] decryptedtext = cipher.doFinal(Data);
out.write(decryptedtext);
}

in.close();
out.close();
}
catch (NoSuchAlgorithmException e1) {
e1.printStackTrace();
}
catch (NoSuchPaddingException e2) {
e2.printStackTrace();
}
catch (Exception e3) {
e3.printStackTrace();
}
catch (NoSuchMethodError e4) {
e4.printStackTrace();
}
}
public void DecryptData(String strEnDataFile, String strDeDataFile)
{
try
{
SecretKeySpec destmp = new SecretKeySpec(this.EncodAndDecodeKey, "DESede");
SecretKey theKey = destmp;

Cipher cipher = Cipher.getInstance("DESede");

cipher.init(2, theKey);
FileInputStream in = new FileInputStream(strEnDataFile);
FileOutputStream out = new FileOutputStream(strDeDataFile);
int len;
while ((len = in.read()) > 0) {
byte[] Data = new byte[len];
in.read(Data);
byte[] decryptedtext = cipher.doFinal(Data);
out.write(decryptedtext);
}

in.close();
out.close();
}
catch (NoSuchAlgorithmException e1) {
e1.printStackTrace();
}
catch (NoSuchPaddingException e2) {
e2.printStackTrace();
}
catch (Exception e3) {
e3.printStackTrace();
}
catch (NoSuchMethodError e4) {
e4.printStackTrace();
}
}
}

以上是java的一个加密解密算法,现在要根据这个算法编写C#算法,请各位高手给出代码。多谢。分不够可以加,在线等。
...全文
44 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

58,454

社区成员

发帖
与我相关
我的任务
社区描述
Java Eclipse
社区管理员
  • Eclipse
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧