Encryption in 1.1, Decryption in 2.0


F

Frank

Could anyone provide and example/link to how I could encrypt data in 1.1 and
decrypt in 2.0? I think I need to use 3DES
 
Ad

Advertisements

J

Jon Skeet [C# MVP]

Could anyone provide and example/link to how I could encrypt data in 1.1 and
decrypt in 2.0? I think I need to use 3DES

You should be able to use the same code you would have used to decrypt
in 1.1. If you're running into issues, please give more details.

Jon
 
Ad

Advertisements

?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

Frank said:
Could anyone provide and example/link to how I could encrypt data in 1.1 and
decrypt in 2.0? I think I need to use 3DES

A simple 3DES example is attached below. It should work in both 1.1
and 2.0.

Arne

==========================

using System;
using System.Text;
using System.Security.Cryptography;

class MainClass
{
public static void Main(string[] args)
{
Encoding utf = new UTF8Encoding();
TripleDES des3 = new TripleDESCryptoServiceProvider();
byte[] key = utf.GetBytes("hemmeligabcdefgh12345678");
byte[] iv = { 1, 2, 3, 4, 5, 6, 7, 8 };
ICryptoTransform encrypt = des3.CreateEncryptor(key, iv);
String plain1 = "Dette er en lille test";
byte[] cipher =
encrypt.TransformFinalBlock(utf.GetBytes(plain1), 0,
utf.GetByteCount(plain1));
for(int i = 0; i < cipher.Length; i++)
{
Console.WriteLine(cipher);
}
ICryptoTransform decrypt = des3.CreateDecryptor(key, iv);
String plain2 =
utf.GetString(decrypt.TransformFinalBlock(cipher, 0, cipher.Length));
Console.WriteLine(plain2);
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top