Hello NG,
How can I decrypt an des ede3 encrypted string with .NET? The string was encrypted by using the OpenSSL Method des-ede3-cbc.
Thank You!
Joachim 3 6171
Joachim,
I think what you want is the TripleDESCryptoServiceProvider class in the
System.Security.Cryptography namespace.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"v.Seydewitz" <seydewitzgmxnet> wrote in message
news:ev*************@TK2MSFTNGP10.phx.gbl... Hello NG,
How can I decrypt an des ede3 encrypted string with .NET? The string was encrypted by using the OpenSSL Method des-ede3-cbc.
Thank You! Joachim
Hello Nicholas, I think what you want is the TripleDESCryptoServiceProvider class in the System.Security.Cryptography namespace.
I have already tried the sample from the System.Security.Cryptography.TripleDESCryptoServic eProvider namespace. I need to decrypt a
string which was encrypted with openssl:
openssl enc -des-ede3-cbc -K 01234567890ABCEF12345678 -iv 12345678 -e -in in.txt -out out.txt
Decrypting the out.txt file with openssl works fine, but when I decrypt the out.txt with the following code, I get an error at
decStream.Close() "Bad Data.\r\n" and the written textfile contains unreadable text instead of the decoded text.
---- modified Code from MSDN ----
private static void DecryptData(String inName, String outName, byte[] tdesKey, byte[] tdesIV)
{
try
{
//Create the file streams to handle the input and output files.
FileStream fin = new FileStream(inName, FileMode.Open, FileAccess.Read);
FileStream fout = new FileStream(outName, FileMode.OpenOrCreate, FileAccess.Write);
fout.SetLength(0);
//Create variables to help with read and write.
byte[] bin = new byte[100]; //This is intermediate storage for the encryption.
long rdlen = 0; //This is the total number of bytes written.
long totlen = fin.Length; //This is the total length of the input file.
int len; //This is the number of bytes to be written at a time.
TripleDESCryptoServiceProvider tdes = new TripleDESCryptoServiceProvider();
tdes.Mode = CipherMode.CBC;
CryptoStream decStream = new CryptoStream(fout, tdes.CreateDecryptor(tdesKey, tdesIV), CryptoStreamMode.Write);
Console.WriteLine("Decrypting ...");
//Read from the input file, then encrypt and write to the output file.
while(rdlen < totlen)
{
len = fin.Read(bin, 0, 100);
decStream.Write(bin, 0, len);
rdlen = rdlen + len;
Console.WriteLine("{0} bytes processed", rdlen);
}
decStream.Close();
}
catch(System.Exception ex){
Console.WriteLine(ex.Message);
}
}
-----
Thank You
/Joachim Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"v.Seydewitz" <seydewitzgmxnet> wrote in message news:ev*************@TK2MSFTNGP10.phx.gbl... Hello NG,
How can I decrypt an des ede3 encrypted string with .NET? The string was encrypted by using the OpenSSL Method des-ede3-cbc.
Thank You! Joachim
It's working now. I had an error in my code when i converted the key to bytes.
Thank you!
/Joachim
"v.Seydewitz" <seydewitzgmxnet> wrote in message news:ev*************@TK2MSFTNGP10.phx.gbl... Hello NG,
How can I decrypt an des ede3 encrypted string with .NET? The string was encrypted by using the OpenSSL Method des-ede3-cbc.
Thank You! Joachim This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Benoît |
last post by:
Hi,
I have generated two keys :
"C:>openssl req -nodes -new -x509 -keyout ben.key -out ben.crt -days
3650"
I try to encrypt/decrypt a string like "JOHN" with these asymetrics
keys. With the...
|
by: v.Seydewitz |
last post by:
Hello, how can I decrypt an des-ede3-cbc encrypted string by using .NET? I haven't found an appropriate method in the
System.Security.Cryptography namespace.
Thank You!
Joachim
|
by: Dica |
last post by:
i've used the sample code from msdn to create an encyption/decryption
assembly as found here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/SecNetHT10.asp
i'm...
|
by: chuayl |
last post by:
im a newbie in this encrypt/decryption standard.
Can i know what is "DES-EDE3/ECB/NONE" algorithm ?
Do we have to set the Vector for this ?
what if we do not have a vector for this ?
|
by: Hannibal111111 |
last post by:
I found this code on a site for doing string encryption/decryption.
The string will encrypt fine, but I get this error when I try to
decrypt. Any idea why? I posted the code below.
The error...
| |
by: JDeats |
last post by:
I have some .NET 1.1 code that utilizes this technique for encrypting
and decrypting a file.
http://support.microsoft.com/kb/307010
In .NET 2.0 this approach is not fully supported (a .NET 2.0...
|
by: MimiMi |
last post by:
I'm trying to decrypt a byte array in java that was encrypted in C#. I don't get any error messages, just a result that's completely not what I was hoping for.
I think I am using the same type of...
|
by: MimiMi |
last post by:
I'm trying to decrypt a byte array in java that was encrypted in C#. I don't get any error messages, just a result that's completely not what I was hoping for.
I think I am using the same type of...
|
by: bferguson94 |
last post by:
Design a program that allows the user to encrypt or decrypt a file.
This means you will need to ask the user the direction to shift (left or right) and the number of places to shift (should they...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |