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

gralei gralei 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
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#算法,请各位高手给出代码。多谢。分不够可以加,在线等。
...全文

相关推荐

评论
收藏 已收藏
分享
返回顶部
gralei
Eclipse 58,439 成员 49,457 内容