以上是java的一个加密解密算法,现在要根据这个算法编写C#算法,请各位高手给出代码。多谢。分不够可以加,在线等。
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#算法,请各位高手给出代码。多谢。分不够可以加,在线等。
{
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#算法,请各位高手给出代码。多谢。分不够可以加,在线等。
...全文
相关推荐
C#与java平台RSA加密解密签名验签互通案例
在这个案例中,"Test"和"Javaworkspace"可能是包含代码示例或者测试数据的文件夹,可能包含C#和Java的实现代码,用于演示如何处理上述步骤,以实现RSA加密解密和签名验签的互通。
C# Java间进行RSA加密解密交互(二)
接着前面一篇文章C# Java间进行RSA加密解密交互,继续探讨这个问题。
C++/java/C#语言的AES加密解密
根据压缩包子文件的文件名称,我们可以进一步分析:1. `AES.java`:这是Java语言实现的AES加密解密代码。
Rsa加签验签,加密解密(对接java,亲测,好用).7z
通过以上步骤,你可以实现C#和Java之间的RSA加签、验签、加密和解密操作,确保数据安全和对接顺利。在实际开发中,应根据具体需求调整和优化这些步骤。
C#的3DES加密解密算法实例代码
"C#实现3DES加密解密的实例代码示例"在本文中,我们将深入探讨C#中用于3DES(Triple DES)加密解密的实现方式。3DES是一种加强版的DES(Data Encryption Sta


Eclipse
